Source Code
#include <bits/stdc++.h>

using namespace std;

#define modulo ll (1e9 + 7)
#define neig(a, u, e, v) for(int v, e = (a).head[u] ; ~e and (v = (a).to[e], 1) ; e = (a).nxt[e])

typedef long long ll;

const int N = 2e5 + 9, M = 1e6 + 9, OO = 0x3f3f3f3f;
const ll llOO = 0x3f3f3f3f3f3f3f3f;


int main() {
    cin.tie(0);
    cin.sync_with_stdio(0);

    ll n, a, b; cin >> n >> a >> b;


    ll l = 1, r = llOO;
    while(l <= r){
        ll mid = (l + r) >> 1;
        ll totalSolved = (mid / a) + (mid / b);
        if(totalSolved >= n)
            r = mid - 1;
        else
            l = mid + 1;
    }

    cout << l;
}
Copy
Hurry up Muhammad
GNU G++17
0 ms
788 KB
Accepted