mirror of
https://git.sb/baoshuo/OI-codes.git
synced 2024-11-27 17:16:28 +00:00
1289. 序列的第k个数
https://www.acwing.com/problem/content/submission/code_detail/13569668/
This commit is contained in:
parent
bb5b027079
commit
68c50e8c8a
38
AcWing/1289/1289.cpp
Normal file
38
AcWing/1289/1289.cpp
Normal 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
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
BIN
AcWing/1289/data/2.in
(Stored with Git LFS)
Normal file
Binary file not shown.
Loading…
Reference in New Issue
Block a user