You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
28 lines
723 B
28 lines
723 B
#include <bits/stdc++.h>
|
|
using namespace std;
|
|
#define int long long
|
|
const int MOD = 200907;
|
|
|
|
// 快速幂
|
|
int qmi(int a, int b) {
|
|
int res = 1;
|
|
while (b) {
|
|
if (b & 1) res = res * a % MOD;
|
|
a = a * a % MOD;
|
|
b >>= 1;
|
|
}
|
|
return res;
|
|
}
|
|
|
|
signed main() {
|
|
int n;
|
|
cin >> n;
|
|
while (n--) {
|
|
int a, b, c, k;
|
|
cin >> a >> b >> c >> k;
|
|
if (a + c == b * 2) // 等差
|
|
cout << (a + (b - a) * (k - 1)) % MOD << endl; // 这个比较简单
|
|
else // 等比
|
|
cout << a * qmi(b / a, k - 1) % MOD << endl; // 这个需要快速幂
|
|
}
|
|
} |