Source Code
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define fastIO std::ios::sync_with_stdio(false); cin.tie(0);
 
ll noOfProblems, Kitty, Lucy;
 
bool vaild(ll ansTime) {
 
    if(ansTime/Kitty + ansTime/Lucy >= noOfProblems)
        return true;
    return false;
 
}
 
 
int main() {    fastIO
 
    cin>>noOfProblems>>Kitty>>Lucy;
 
    ll L=1, R=1e9, ans=1;
    // O(books * log(books)) = 10^5 * 17 
    while(L<=R) {
        ll mid = (L+R)/2;
        // 0 0 0 0 0 1 1 1 1 
        if(vaild(mid)) {
            ans = mid;
            R = mid-1;
        } else {
            L = mid+1;
        }
    }
    cout<<ans<<endl;
 
    return 0;
}
Copy
Hurry up rubairshaid
GNU G++17
0 ms
368 KB
Wrong Answer