Advertisement
SJMormo

Untitled

Sep 14th, 2020
123
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.97 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3.  
  4. typedef long long ll;
  5. typedef long double ld;
  6.  
  7. const ll mod = 1000000007;
  8.  
  9. #define FOR(i, s, e) for (ll i = s; i < e; i++)
  10. #define FOr(i, s, e) for (ll i = s; i >= e; i--)
  11.  
  12. #define PI acos(-1)
  13.  
  14.  
  15. void fastio()
  16. {
  17.     ios_base::sync_with_stdio(false);
  18.     cin.tie(NULL);
  19.     cout.tie(NULL);
  20. #ifndef ONLINE_JUDGE
  21.     freopen("input.txt", "r", stdin);
  22.     freopen("output.txt", "w", stdout);
  23. #endif
  24. }
  25.  
  26. #define sz 105
  27.  
  28.  
  29. void solve()
  30. {
  31.     ll x, y, k;
  32.     cin >> x >> y >> k;
  33.  
  34.     ll total = k + (y * k);
  35.  
  36.     ll l = 1, h = 1e18, ans = 1e18;
  37.  
  38.     while (l <= h)
  39.     {
  40.         ll mid = (l + h) / 2;
  41.         // cout << mid << ' ';
  42.  
  43.         ll comp = (mid * x) - (mid - 1);
  44.  
  45.         if (comp >= total)
  46.         {
  47.             ans = min(mid, ans);
  48.             h = mid - 1;
  49.         }
  50.         else
  51.             l = mid + 1;
  52.  
  53.         // cout << l << ' ' << h << ' ' << ans << endl;
  54.     }
  55.     cout << ans + k << '\n';
  56.  
  57.  
  58. }
  59.  
  60. int main()
  61. {
  62.     fastio();
  63.  
  64.     int t = 1; cin >> t;
  65.     while (t--)
  66.         solve();
  67.  
  68.     return 0;
  69. }
  70.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement