Advertisement
serega1112

Les

Jan 21st, 2022
842
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1.  
  2. a, k, b, m, x = map(int, input().split())
  3.  
  4.  
  5. l = 0
  6. r = 2 * x // max(a, b) + 1
  7.  
  8. while r - l > 1:
  9.     mid = l + (r - l) // 2
  10.     if mid * a - mid // k * a + mid * b - mid // m * b < x:
  11.         l = mid
  12.     else:
  13.         r = mid
  14.  
  15. print(r)
Advertisement
Advertisement
Advertisement
RAW Paste Data Copied
Advertisement