def is_printed printed return printed False False True True def bisect

 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
def is_printed(t):
printed = (t // x) + (t // y)
return printed >= n - 1
# False False True True
def bisect(left, right):
# (left; right]
while right - left > 1:
mid = (left + right) // 2
print(left, right, mid)
if is_printed(mid):
right = mid
else:
left = mid
return right
x = 2
y = 3
n = 10
t1 = min(x, y)
t_max = (n - 1) * t1
for t in range(t_max):
print(t, is_printed(t))
t_rest = bisect(0, t_max + 1)
print(t_rest)