fork(1) download
  1. #include <iostream>
  2. using namespace std;
  3. int bin_s(int n, int x, int y){
  4. int l=0, r=2e9;
  5. while(l<r){
  6. int m=(l+r)/2;
  7. int k=m/x+m/y;
  8. if(k<n)
  9. l=m+1;
  10. else r=m;
  11. }
  12. return l;
  13. }
  14. int main() {
  15. int n,x,y;
  16. cin>>n>>x>>y;
  17. cout<<bin_s(n-1,x,y)+min(x,y);
  18. return 0;
  19. }
  20.  
Success #stdin #stdout 0.01s 5284KB
stdin
2 3 10
stdout
6