Advertisement
Dennnhhhickk

Untitled

Aug 9th, 2017
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.52 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2.  
  3. using namespace std;
  4. typedef long long ll;
  5. typedef long double ld;
  6. ll n, x, y, ans;
  7.  
  8. bool check(ll m)
  9. {
  10. return m / x + m / y >= n - 1 && m >= 0;
  11. }
  12.  
  13. int main()
  14. {
  15. ios::sync_with_stdio(0);
  16. cin.tie(0);
  17. cout.tie(0);
  18. cin >> n >> x >> y;
  19. ll l = 0, r = n * max(x, y), m, ans = min(x, y);
  20. while (l < r)
  21. {
  22. m = (l + r) / 2;
  23. if (check(m - ans))
  24. r = m;
  25. else
  26. l = m + 1;
  27. }
  28. cout << r << endl;
  29. return 0;
  30. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement