Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- from math import sqrt, ceil
- def is_enough(width, height, amount, side):
- return amount <= (side // width) * (side // height)
- def binary_search(width, height, amount):
- left = 0
- right = ceil(sqrt(amount)) * max(width, height)
- while right - left > 1:
- middle = (left + right) // 2
- if is_enough(width, height, amount, middle):
- right = middle
- else:
- left = middle
- return right
- print(binary_search(*map(int, input().split())))
Advertisement
Add Comment
Please, Sign In to add comment