Advertisement
Guest User

Untitled

a guest
Dec 13th, 2017
69
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.60 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. #include <stdio.h>
  3. #include <algorithm>
  4. #include <vector>
  5. #include <iostream>
  6.  
  7. using namespace std;
  8.  
  9. int x,y;
  10.  
  11. int f(int k){
  12.  
  13. int ans;
  14.  
  15. if(x>y){
  16. ans=(k-y)/x+(k-y)/y+1;
  17. }else{
  18. ans=(k-x)/x+(k-x)/y+1;
  19. }
  20.  
  21. return ans;
  22.  
  23. }
  24.  
  25. int main(){
  26. freopen ("Input.txt","r",stdin);
  27. freopen ("Output.txt","w",stdout);
  28. int n,m;
  29. scanf("%d%d%d",&n,&x,&y);
  30. int l=0;
  31. int r=2000000000;
  32. while(r-l>1){
  33. m=l+(r-l)/2;
  34. if(f(m)>=n){
  35. r=m;
  36. }else{
  37. l=m;
  38. }
  39. }
  40. printf("%d",r);
  41. return 0;
  42. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement