比赛 | 位运算及及其应用题单 | 评测结果 | AAAAAAAAAA |
---|---|---|---|
题目名称 | 取余运算 | 最终得分 | 100 |
用户昵称 | AeeE5x | 运行时间 | 0.029 s |
代码语言 | C++ | 内存使用 | 3.30 MiB |
提交时间 | 2025-01-25 11:10:40 | ||
#include<iostream> #include<cstdio> #include<cstring> #include<algorithm> using namespace std; int n,m; int main(){ freopen("dmod.in","r",stdin); freopen("dmod.out","w",stdout); long long n,m,p; cin>>n>>m>>p; long long ans=1; while(m){ if(m&1) ans=ans*n%p; n=n*n%p; m>>=1; } cout<<ans; return 0; }