Advertisement
SJMormo

Untitled

Sep 14th, 2020
439
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.90 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, mid, comp, ans = h, tmp;
  37.  
  38.     while (l <= h)
  39.     {
  40.         mid = (l + h) / 2;
  41.  
  42.         tmp = mid - k - 1;
  43.  
  44.         comp = x + ((x - 1) * tmp);
  45.  
  46.         if (comp >= total)
  47.         {
  48.             ans = mid;
  49.             h = mid - 1;
  50.         }
  51.         else
  52.             l = mid + 1;
  53.     }
  54.  
  55.     cout << ans << '\n';
  56. }
  57.  
  58. int main()
  59. {
  60.     fastio();
  61.  
  62.     int t = 1; cin >> t;
  63.     while (t--)
  64.         solve();
  65.  
  66.     return 0;
  67. }
  68.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement