输入样例:
2
1 2 3 5
1 2 4 5
输出样例:
5
16
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
using namespace std;
constexpr int N = 1e5;
const int mod = 200907;
int a, b, c, k;
int qmi(int x, int n) {
int res = 1;
while (n) {//对指数进行操作
if (n & 1) res = res * x % mod;
x = x * x % mod;
n >>= 1;
}
return res;
}
void solve1() {
int d = b - a;
int ans = a + (k - 1) * d;
cout << ans % mod << endl;
}
void solve2() {
int q = b / a;
int ans = a * qmi(q, k - 1);
cout << ans%mod << endl;
}
signed main() {
ios_base::sync_with_stdio(0);
cin.tie(0); cout.tie(0);
int T;
cin >> T;
while (T--) {
cin >> a >> b >> c>>k;
bool flag=false;
if (a + c == b + b) {
flag = true;
}//是等差
if (flag) {
solve1();
}
else {
solve2();
}
}
return 0;
}