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.
30 lines
645 B
30 lines
645 B
#include <bits/stdc++.h>
|
|
using namespace std;
|
|
|
|
//快速幂
|
|
typedef long long LL;
|
|
const int mod = 200907;
|
|
int qmi(int a, int k) {
|
|
int res = 1;
|
|
while (k) {
|
|
if (k & 1) res = (LL)res * a % mod;
|
|
a = (LL)a * a % mod;
|
|
k >>= 1;
|
|
}
|
|
return res;
|
|
}
|
|
|
|
int main() {
|
|
int n;
|
|
scanf("%d", &n);
|
|
while (n--) {
|
|
int a, b, c, k;
|
|
scanf("%d%d%d%d", &a, &b, &c, &k);
|
|
if (a + c == b * 2) //等差
|
|
printf("%lld\n", (a + (b - a) * (LL)(k - 1)) % mod);
|
|
else //等比
|
|
printf("%lld\n", (LL)a * qmi(b / a, k - 1) % mod);
|
|
}
|
|
|
|
return 0;
|
|
} |