Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long ll;
- typedef long double ld;
- const ll mod = 1000000007;
- #define FOR(i, s, e) for (ll i = s; i < e; i++)
- #define FOr(i, s, e) for (ll i = s; i >= e; i--)
- #define PI acos(-1)
- void fastio()
- {
- ios_base::sync_with_stdio(false);
- cin.tie(NULL);
- cout.tie(NULL);
- #ifndef ONLINE_JUDGE
- freopen("input.txt", "r", stdin);
- freopen("output.txt", "w", stdout);
- #endif
- }
- #define sz 105
- void solve()
- {
- ll x, y, k;
- cin >> x >> y >> k;
- ll total = k + (y * k);
- ll l = 1, h = 1e18, mid, comp, ans = h, tmp;
- while (l <= h)
- {
- mid = (l + h) / 2;
- tmp = mid - k - 1;
- comp = x + ((x - 1) * tmp);
- if (comp >= total)
- {
- ans = mid;
- h = mid - 1;
- }
- else
- l = mid + 1;
- }
- cout << ans << '\n';
- }
- int main()
- {
- fastio();
- int t = 1; cin >> t;
- while (t--)
- solve();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement