Source Code
#include <bits/stdc++.h>
using namespace std;

int main(){
	int n,x,y;
	cin>>n>>x>>y;
	long long ans = 0;
	long long high = 1e18, low = 0;
	while(high>=low){
		long long mid = (high+low)/2;

		long long time = mid/y + mid/x;
		// cout<<mid<<" ----> "<<time<<endl;
		if(time >= n){
			high = mid-1;
			ans = mid;
		}
		else
			low = mid+1;
	}
	cout<<ans;
}
Copy
Hurry up hashemtb
GNU G++17
5 ms
356 KB
Accepted