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. cout<<l<<" "<<r<<endl;
  12. }
  13.  
  14. return l;
  15. }
  16. int main() {
  17. int n,x,y;
  18. cin>>n>>x>>y;
  19. cout<<bin_s(n-1,x,y)+min(x,y);
  20. return 0;
  21. }
  22.  
Success #stdin #stdout 0.01s 5272KB
stdin
2 3 10
stdout
0 1000000000
0 500000000
0 250000000
0 125000000
0 62500000
0 31250000
0 15625000
0 7812500
0 3906250
0 1953125
0 976562
0 488281
0 244140
0 122070
0 61035
0 30517
0 15258
0 7629
0 3814
0 1907
0 953
0 476
0 238
0 119
0 59
0 29
0 14
0 7
0 3
2 3
3 3
6