Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import math
- sh = False
- def f(A):
- if sh:
- print("A = ", A)
- to2 = int(math.log(A, 2) + 10)
- to3 = int(math.log(A, 3) + 10)
- to5 = int(math.log(A, 5) + 10)
- best = 10 ** 19
- for i5 in range(to5):
- for i3 in range(to3):
- ch = 5**i5 * 3**i3
- if sh:
- print("i5 = ", i5)
- print("i3 = ", i3)
- if ch >= A:
- best = min(best, ch)
- continue
- i2 = int(math.log(A // (5 ** i5 * 3 ** i3), 2))
- if (5 ** i5 * 3 ** i3 * 2 ** i2 < A):
- i2 += 1
- now = 5 ** i5 * 3 ** i3 * 2 ** i2
- best = min(best, now)
- return best
- n = int(input())
- ar = []
- for i in range(n):
- x = int(input())
- ar.append(x)
- for i in ar:
- print(f(i))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement