Advertisement
Guest User

Untitled

a guest
Feb 28th, 2020
109
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.73 KB | None | 0 0
  1. #include <iostream>
  2. #include <fstream>
  3. #include <iomanip>
  4. #include <string>
  5. #include <vector>
  6. #include <algorithm>
  7. #include <cmath>
  8. #include <math.h>
  9. #include <set>
  10. #include <map>
  11. #include <queue>
  12. #include <deque>
  13. #include <stack>
  14.  
  15.  
  16.  
  17. using namespace std;
  18.  
  19.  
  20.  
  21. int main()
  22. {
  23. ios_base::sync_with_stdio(false);
  24. cin.tie(0);
  25.  
  26. unsigned long long a, k, b, kk, x;
  27. cin >> a >> k >> b >> kk >> x;
  28.  
  29. unsigned long long d = 0, f = 0, ans = 0;
  30. unsigned long long l = 0;
  31. unsigned long long r = 2 * x / (a + b) + 1;
  32.  
  33. while (r - l > 1)
  34. {
  35. ans = (r + l) / 2;
  36. d = (ans * a) - ((ans / k) * a);
  37. f = (ans * b) - ((ans / kk) * b);
  38. if (d + f >= x) r = ans;
  39. else l = ans;
  40. }
  41.  
  42. cout << ans;
  43.  
  44. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement