Source Code
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
int main()
{
    fastIO
    ll n,x,y;cin>>n>>x>>y;
    ll l=0,r=1e18,ans;
    while(l<=r)
    {
        ll mid=(l+r)/2;
        ll temp=(mid/x)+(mid/y);
        if(temp>=n)
        {
            ans=mid;
            r=mid-1;
        }
        else l=mid+1;
    }
    cout<<ans<<endl;
}
Copy
Hurry up 3am0rab1
GNU G++17
0 ms
876 KB
Accepted