Advertisement
Korotkodul

F_py3

Dec 10th, 2022
910
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.59 KB | None | 0 0
  1. n = int(input())
  2. ar = []
  3. for i in range(n):
  4.     x = int(input())
  5.     ar.append(x)
  6.  
  7. def get(i2, i3, i5):
  8.     return 2**i2 * 3**i3 * 5**i5
  9.  
  10.  
  11. import math
  12. def f(A):
  13.     bst = 10**20
  14.     for i5 in range(28):
  15.         for i3 in range(40):
  16.             rest = A // (5**i5 * 3**i3)
  17.             if rest < 1:
  18.                 bst = min(bst, 5**i5 * 3**i3)
  19.                 continue
  20.             i2 = int(math.log2(rest))
  21.             res = get(i2, i3, i5)
  22.             if  res < A:
  23.                 res *= 2
  24.             bst = min(bst, res)
  25.     return bst
  26.  
  27. for i in ar:
  28.     print(f(i))
  29.            
  30.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement