-
-
Save meooow25/e4f012a2e15176fe33344ee5ddba6d22 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <bits/stdc++.h> | |
using namespace std; | |
int main() { | |
ios_base::sync_with_stdio(false); cin.tie(NULL); | |
int T; cin >> T; | |
while (T--) { | |
int p, q, N; | |
cin >> p >> q >> N; N--; | |
int den = 2 * abs(p - q); | |
long long num = 1LL * N * q; | |
long long ans = num / den + 1; | |
cout << ans << "\n"; | |
} | |
return 0; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment