Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- int a, k, b, m, x;
- cin >> a >> k >> b >> m >> x;
- int l = -1, r = 1e18;
- while(r - l > 1) {
- int mid = (r + l) >> 1;
- int cnt = (mid * a - (mid / k) * a) + (mid * b - (mid / m) * b);
- if(cnt >= x) {
- // cerr << mid << " " << cnt << '\n';
- r = mid;
- }
- else {
- l = mid;
- }
- }
- cout << r;
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement