比赛 | 板子大赛 | 评测结果 | AAWWWWWWWW |
---|---|---|---|
题目名称 | 取余运算 | 最终得分 | 20 |
用户昵称 | IMZ | 运行时间 | 0.031 s |
代码语言 | C++ | 内存使用 | 3.49 MiB |
提交时间 | 2025-01-22 13:42:17 | ||
#include <bits/stdc++.h> using namespace std; char s[100010]; int a,n,p; int mi(int x){ if(x==0){ return 1; } if(x==1){ return a; } int t=mi(x/2); if(x%2==0){ return ((t%p)*(t%p))%p; } else{ return ((t%p)*(t%p)*(a%p))%p; } } int main(){ freopen("dmod.in","r",stdin); freopen("dmod.out","w",stdout); scanf("%d%d%d",&a,&n,&p); long long ret=mi(n); printf("%lld",ret); return 0; }