Skip to content

Instantly share code, notes, and snippets.

@meooow25
Created April 15, 2018 00:17
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save meooow25/e4f012a2e15176fe33344ee5ddba6d22 to your computer and use it in GitHub Desktop.
Save meooow25/e4f012a2e15176fe33344ee5ddba6d22 to your computer and use it in GitHub Desktop.
#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