треугольные и квадратные числа n = int(input()) L = [1] k = 2 while L[-1] < n: L.append(L[-1] + k) k += 1 count_1 = 0 count_2 = len(L) - 1 ans = 0 while count_1 < count_2: if L[count_1] + L[count_2] == n: ans += 1 #print(L[count_1], L[count_2]) count_2 -= 1 elif L[count_1] + L[count_2] > n: count_2 -= 1 else: count_1 += 1 print(ans) очень легкая задача: поразрядное приближение n, x, y = map(int, input().split()) ans = 0 n -= 1 step = 10 ** 9 while step > 0: while n > ans // x + ans // y: ans += step if step > 1: ans -= step step //= 10 print(ans + min(x, y)) Вырубка леса a, k, b, m, x = map(int, input().split()) left = -1 right = 10 ** 20 while right - left > 1: middle = (left + right) // 2 if x <= a * (middle - middle // k) + b * (middle - middle // m): right = middle else: left = middle print(right)