Skip to content

Instantly share code, notes, and snippets.

@flutesa
Created December 9, 2013 16:23
Show Gist options
  • Save flutesa/7875085 to your computer and use it in GitHub Desktop.
Save flutesa/7875085 to your computer and use it in GitHub Desktop.
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