| 比赛 | 位运算及及其应用题单 | 评测结果 | AAAAAAAAAA |
|---|---|---|---|
| 题目名称 | 取余运算 | 最终得分 | 100 |
| 用户昵称 | 梦那边的美好CE | 运行时间 | 0.029 s |
| 代码语言 | C++ | 内存使用 | 3.49 MiB |
| 提交时间 | 2025-01-25 11:14:44 | ||
#include <bits/stdc++.h>
using namespace std;
long long b, a, p, k, ans = 1, c;
int main() {
freopen("dmod.in","r",stdin);freopen("dmod.out","w",stdout);
scanf("%lld%lld%lld", &b, &p, &k);
a = b;
c = p;
while (p > 0) {
if (p % 2 != 0)
ans = ans * b % k;
b = b * b % k;
p = p >> 1;
}
ans %= k;
printf("%lld", ans);
return 0;
}