Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- typedef long double ld;
- ll n, x, y, ans;
- bool check(ll m)
- {
- return m / x + m / y >= n - 1 && m >= 0;
- }
- int main()
- {
- ios::sync_with_stdio(0);
- cin.tie(0);
- cout.tie(0);
- cin >> n >> x >> y;
- ll l = 0, r = n * max(x, y), m, ans = min(x, y);
- while (l < r)
- {
- m = (l + r) / 2;
- if (check(m - ans))
- r = m;
- else
- l = m + 1;
- }
- cout << r << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement