-
Notifications
You must be signed in to change notification settings - Fork 0
/
V19.py
106 lines (83 loc) · 2.65 KB
/
V19.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
# Solved by Ostap Baranov in preparation for the Russian Unified State Exam in CS, 2023.
#
# All tasks were developed by Krulov S. S. in 2023 and belongs to the © National Education Publishing, LLC.
from turtle import *
from math import floor, ceil, log, sqrt
from itertools import product, permutations
from functools import lru_cache
print("№2:") # zwyx
def columns(y, x, w, z):
return not(y <= x) or (y == w) or z
for holes in product((0, 1), repeat=6):
table = [(holes[0], 1, holes[1], 1), (0, holes[2], 1, 1), (holes[3], 1, holes[4], holes[5])]; F = [0, 0, 0]
if len(table) == len(set(table)):
for answer2 in permutations('yxwz'):
print(*answer2, sep='') if [columns(**dict(zip(answer2, variations))) for variations in table] == F else None
print("№5:") # 96
for N in range(1, 100):
R = (N * 4) + (N % 4)
if R < 100:
print(R)
print("№6:") # 269
screensize(5000, 5000)
ht()
tracer(0)
speed(10)
color("white", "red")
scale = 40
counter6 = 0
begin_fill()
lt(90)
rt(300)
for rep in range(4):
fd(10 * scale)
rt(120)
fd(10 * scale)
rt(330)
end_fill()
up()
canvas = getcanvas()
for X in range(-200 * scale, 200 * scale, scale):
for Y in range(-200 * scale, 200 * scale, scale):
scan = canvas.find_overlapping(X, Y, X, Y)
counter6 += 1 if len(scan) == 1 and scan[0] == 5 else 0
print(counter6)
update()
exitonclick()
print("№8:") #
print("№12:") #
print("№14:") #
print("№15:") #
print("№16:") # 43
@lru_cache(None)
def F(n):
if n == 1:
return 1
elif n == 2:
return 2
elif n > 2 and n % 2 == 0:
return (7 * n + F(n - 3)) // 9 # Простенькая реализация взятия целой части числа
elif n > 2 and n % 2 != 0:
return (5 * n + F(n - 1) + F(n - 2)) // 7
print(F(50))
print("№17:") #
print("№19:") #
print("№20:") #
print("№21:") #
print("№23:") # 12
func23 = lambda start, end, exc: func23(start + 1, end, exc) + func23(start * 2, end, exc) if start < end and start != exc else start == end
print(func23(3, 12, 23) * func23(12, 27, 23))
print("№24:") #
print("№25:") # Ответ верный
def isPrime(number):
return number > 1 and all(number % divider != 0 for divider in range(2, int(number ** 0.5) + 1))
def divs(number):
s = set()
for divider in range(2, int(number ** 0.5) + 1):
if number % divider == 0:
s.add(divider); s.add(number // divider)
return sorted(s)
for number in range(550_001, 556_001):
d = divs(number)
S = sum([index for index in d if isPrime(index)])
print(number, S) if S % 10 == 1 else None