Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import sys
- import math
- r = float(input())
- max_value = int(input())
- min_value = sys.maxsize
- for q in range(1, max_value + 1)[::-1]:
- t = r * q
- float_value = (int(t + 1)) / q
- if math.fabs(float_value - r) <= min_value:
- result_T = int(t + 1)
- result_Q = q
- min_value = math.fabs(float_value - r)
- float_value = (int(t)) / q
- if math.fabs(float_value - r) <= min_value:
- result_T = int(t)
- result_Q = q
- min_value = math.fabs(float_value - r)
- print(result_T, result_Q)
- n = int(input())
- a = [0] * (n + 1)
- count = 0
- for i in range(1, n + 1):
- for j in range(2, n // i + 1):
- a[i * j] += i
- if (a[i] <= n) and (a[a[i]] <= n):
- if (i == a[a[i]]) and (i < a[i]):
- print(i, a[i])
- count += 1
- print("Result:", count)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement