Source Code

#include<bits/stdc++.h>
using namespace std;
int main(){
int x,y,z,ans;
cin>>x>>y>>z;
int r=x*max(y,z),l=1,mid;
while(l<=r){
mid=(l+r)/2;
if(mid/y+mid/z==x){
  ans=mid;
  r=mid-1;
}
if(mid/y+mid/z<x)l=mid+1;
else r=mid-1;
}
cout<<ans;
}
Copy
Hurry up hasneen
GNU G++17
0 ms
388 KB
Wrong Answer