Created
December 9, 2013 16:23
-
-
Save flutesa/7875085 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def isAnswer(m, n, x, y): | |
return (m//x) + (m//y) >= n | |
def find(n, x, y): | |
l = 0 | |
r = n * x | |
while l + 1 < r: | |
m = (l + r)//2 | |
if isAnswer(m, n, x, y): | |
print("time = ", m, "count = ", ((m//x) + (m//y))) | |
r = m | |
else: | |
l = m | |
return r | |
n, x, y = list(map(int, input().split())) | |
if x < y: | |
x, y = y, x | |
print(find(n - 1, x, y) + y) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment