Advertisement
GerONSo

Untitled

Sep 19th, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.38 KB | None | 0 0
  1. int a, k, b, m, x;
  2. cin >> a >> k >> b >> m >> x;
  3. int l = -1, r = 1e18;
  4. while(r - l > 1) {
  5. int mid = (r + l) >> 1;
  6. int cnt = (mid * a - (mid / k) * a) + (mid * b - (mid / m) * b);
  7. if(cnt >= x) {
  8. // cerr << mid << " " << cnt << '\n';
  9. r = mid;
  10. }
  11. else {
  12. l = mid;
  13. }
  14. }
  15. cout << r;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement