Raslboyy

490

Nov 10th, 2019
190
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.08 KB | None | 0 0
  1. #include <iostream>
  2. //#include <chrono>
  3. //#include <fstream>
  4. //#include <bits/stdc++.h>
  5. #include <algorithm>
  6.  
  7. #define mp make_pair
  8. #define pb push_back
  9. #define eb emplace_back
  10. #define f first
  11. #define s second
  12. #define sz(x) (int)x.size()
  13. #define all(x) begin(x), end(x)
  14. #define rall(x) rbegin(x), rend(x)
  15.  
  16. using namespace std;
  17.  
  18. typedef unsigned long long ull;
  19. typedef long long ll;
  20. typedef long double ld;
  21. typedef pair<int, int> pi;
  22. typedef pair<ll, ll> pl;
  23.  
  24. int main() {
  25.     /*ifstream cin("in.txt");
  26.     ofstream cout("out.txt");
  27.     auto start_time = chrono::high_resolution_clock::now();*/
  28.  
  29.     ios::sync_with_stdio(false);
  30.     cin.tie(0);
  31.     cout.tie(0);
  32.  
  33.    
  34.     int x, y, n;
  35.     cin >> n >> x >> y;
  36.     int l = -1, r = max(x, y) * n;
  37.     while (l + 1 < r) {
  38.         int mid = (l + r) / 2;
  39.         if (mid / x + mid / y < n - 1)
  40.             l = mid;
  41.         else
  42.             r = mid;
  43.     }
  44.     cout << r + min(x, y) << endl;
  45.  
  46.    
  47.     /*auto end_time = chrono::high_resolution_clock::now();
  48.     chrono::duration<double> duration = end_time - start_time;
  49.     cout << duration.count() << "\n";
  50.     cin.close();
  51.     cout.close();*/
  52.     return 0;
  53. }
Advertisement
Add Comment
Please, Sign In to add comment