用户输出
25646167
系统信息
Exited with return code 0
编号 | 题目 | 状态 | 分数 | 总时间 | 内存 | 代码 / 答案文件 | 提交者 | 提交时间 |
---|---|---|---|---|---|---|---|---|
#100670 | #110. czq的模法数列 | Accepted | 100 | 128 ms | 268 K | C++ 11 (NOI) / 498 B | 明勇 | 2023-08-09 12:54:14 |
#include <bits/stdc++.h>
using namespace std;
long long calculate(long long int base, long long int exp_1, long long mod) {
long long res = 1;
while (exp_1) {
if (exp_1 & 1)
res = ((res * base) % mod + mod) % mod;
exp_1 >>= 1;
base = (base * base) % mod;
}
return res;
}
int main() {
long long n, k, mod;
scanf("%lld %lld %lld", &n, &k, &mod);
long long sum = 0;
for (int i = 0; i < n; i++) {
sum += calculate(k, i, mod);
}
sum %= mod;
cout << sum;
return 0;
}
用户输出
192041748
系统信息
Exited with return code 0
用户输出
917164423
系统信息
Exited with return code 0
用户输出
626438667
系统信息
Exited with return code 0