0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-23 20:28:48 +00:00

#10193. 「一本通 6.1 例 1」序列的第 k 个数

https://loj.ac/s/1025637
This commit is contained in:
Baoshuo Ren 2021-01-03 10:20:25 +08:00 committed by Baoshuo Ren
parent 837ed43d29
commit c830ea65ac
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68

31
LibreOJ/10193/10193.cpp Normal file
View File

@ -0,0 +1,31 @@
#include <bits/stdc++.h>
using namespace std;
const int mod = 200907;
long long binpow(long long a, long long b) {
a %= mod;
long long res = 1;
while (b > 0) {
if (b & 1) res = res * a % mod;
a = a * a % mod;
b >>= 1;
}
return res;
}
int main() {
int t;
cin >> t;
while (t--) {
long long a, b, c, k;
cin >> a >> b >> c >> k;
if (b - a == c - b) {
cout << (a + (b - a) % mod * (k - 1)) % mod << endl;
} else if (b / a == c / b) {
cout << a * binpow(b / a, k - 1) % mod << endl;
}
}
return 0;
}