Source Code
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#define all(v) v.begin(), v.end()
#define pb push_back    
#define sz(x) (int)(x).size()
const int N = 3e5 + 5;
void solve() {
    ll n,x,y;
    scanf("%lld%lld%lld",&n,&x,&y);
    ll s = 1, e = max(x,y)*n, ans = min(x,y)*n;
    while(s <= e){
        ll md = (s+e)/2LL;
        if(md/x+md/y >= n) ans = min(md,ans), e = md - 1;
        else s = md + 1;
    }
    printf("%lld", ans);
}
int main() {
    int t = 1;
    // scanf("%d",&t);
    while(t--)
        solve();
}
Copy
Hurry up Kamoon
GNU G++17
0 ms
752 KB
Accepted