0
1
mirror of https://git.sb/baoshuo/OI-codes.git synced 2024-11-08 12:58:48 +00:00

1289. 序列的第k个数

https://www.acwing.com/problem/content/submission/code_detail/13569668/
This commit is contained in:
Baoshuo Ren 2022-04-20 21:01:40 +08:00
parent bb5b027079
commit 68c50e8c8a
Signed by: baoshuo
GPG Key ID: 70F90A673FB1AB68
3 changed files with 44 additions and 0 deletions

38
AcWing/1289/1289.cpp Normal file
View File

@ -0,0 +1,38 @@
#include <iostream>
using std::cin;
using std::cout;
const char endl = '\n';
const int mod = 200907;
int t, a, b, c, k;
int binpow(int a, int b) {
int res = 1;
a %= mod;
while (b) {
if (b & 1) res = 1ll * res * a % mod;
a = 1ll * a * a % mod;
b >>= 1;
}
return res;
}
int main() {
std::ios::sync_with_stdio(false);
cin >> t;
while (t--) {
cin >> a >> b >> c >> k;
if (a - b == b - c) { // 等差数列
cout << (a + 1ll * (b - a) * (k - 1)) % mod << endl;
} else { // 等比数列
cout << 1ll * a * binpow(b / a, k - 1) % mod << endl;
}
}
return 0;
}

BIN
AcWing/1289/data/2.ans (Stored with Git LFS) Normal file

Binary file not shown.

BIN
AcWing/1289/data/2.in (Stored with Git LFS) Normal file

Binary file not shown.