Source Code
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned long long
#define sz(s)    (int)(s.size())
#define endl "\n"
#define PI acos(-1)
#define all(a) a.begin(), a.end()
void Open() {
   // freopen("in.txt", "r", stdin);
   // freopen("out.txt", "w", stdout);
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
int dx[]{ 1, -1, 0, 0, 1, 1, -1, -1 };
int dy[]{ 0, 0, 1, -1, 1, -1, 1, -1 };
const int OO = 0x3f3f3f3f;
 
int main()
{
    Open(); 
    int n,x,y;
    cin>>n>>x>>y;
    ll st=1,ed=1e18,cur=-1,md;
    while(st<=ed){
      md=(st+ed)/2;
      if(md/x+md/y>=n){
        cur=md;
        ed=md-1;
      }
      else st=md+1;
    }
    cout<<cur<<endl;
    
}
Copy
Hurry up matb3aa
GNU G++17
0 ms
768 KB
Accepted