编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#20734 | #1029. 寒域爷的兔子 | Accepted | 100 | 234 ms | 372 K | C++ / 877 B | kong | 2019-08-01 16:39:08 |
#include <cstdio>
#include <iostream>
using namespace std;
struct mt22 {
int a, b;
int c, d;
};
struct mt21 {
int a;
int c;
};
int k;
mt22 upp = { 1, 1, 1, 0 };
mt21 sta = { 1, 0 };
unsigned long long m;
mt21 mip(mt22 x, mt21 y) {
mt21 tmp;
tmp.a = (1LLU * x.a * y.a + 1LLU * x.b * y.c) % k;
tmp.c = (1LLU * x.c * y.a + 1LLU * x.d * y.c) % k;
return tmp;
}
mt22 mip(mt22 x, mt22 y) {
mt22 tmp;
tmp.a = (1LLU * x.a * y.a + 1LLU * x.b * y.c) % k;
tmp.b = (1LLU * x.a * y.b + 1LLU * x.b * y.d) % k;
tmp.c = (1LLU * x.c * y.a + 1LLU * x.d * y.c) % k;
tmp.d = (1LLU * x.c * y.b + 1LLU * x.d * y.d) % k;
return tmp;
}
mt22 fast_pow(mt22 x, unsigned long long b) {
mt22 tmp = { 1, 0, 0, 1 };
while (b > 0) {
if (b & 1)
tmp = mip(x, tmp);
x = mip(x, x);
b = b >> 1;
}
return tmp;
}
int main() {
int ans;
cin >> m >> k;
upp = fast_pow(upp, m);
sta = mip(upp, sta);
ans = (2 * sta.c) % k;
cout << ans;
return 0;
}
用户输出
5770
系统信息
Exited with return code 0
用户输出
27662
系统信息
Exited with return code 0
用户输出
8791
系统信息
Exited with return code 0
用户输出
6732
系统信息
Exited with return code 0
用户输出
1454
系统信息
Exited with return code 0
用户输出
3790
系统信息
Exited with return code 0
用户输出
11690
系统信息
Exited with return code 0
用户输出
2151
系统信息
Exited with return code 0
用户输出
1617
系统信息
Exited with return code 0
用户输出
10509
系统信息
Exited with return code 0
用户输出
4380
系统信息
Exited with return code 0
用户输出
2560
系统信息
Exited with return code 0
用户输出
1938
系统信息
Exited with return code 0
用户输出
10705
系统信息
Exited with return code 0
用户输出
9350
系统信息
Exited with return code 0
用户输出
8076
系统信息
Exited with return code 0
用户输出
7210
系统信息
Exited with return code 0
用户输出
666
系统信息
Exited with return code 0
用户输出
16089
系统信息
Exited with return code 0
用户输出
5065
系统信息
Exited with return code 0
用户输出
9362
系统信息
Exited with return code 0
用户输出
9370
系统信息
Exited with return code 0
用户输出
4198
系统信息
Exited with return code 0
用户输出
4041
系统信息
Exited with return code 0
用户输出
4361
系统信息
Exited with return code 0
用户输出
11702
系统信息
Exited with return code 0
用户输出
13980
系统信息
Exited with return code 0
用户输出
1442
系统信息
Exited with return code 0
用户输出
24628
系统信息
Exited with return code 0
用户输出
6954
系统信息
Exited with return code 0
用户输出
5562
系统信息
Exited with return code 0