比赛 | 位运算及及其应用题单 | 评测结果 | AAAAAAAAAA |
---|---|---|---|
题目名称 | 取余运算 | 最终得分 | 100 |
用户昵称 | dy | 运行时间 | 0.030 s |
代码语言 | C++ | 内存使用 | 3.30 MiB |
提交时间 | 2025-01-25 11:15:40 | ||
#include<bits/stdc++.h> using namespace std; #define ll long long ll solve(ll a,ll b,ll p) { ll res=1,base=a; while(b) { if(b&1)res = (res*base)%p; base = (base*base)%p; b>>=1; } return res; } int main() { freopen("dmod.in","r",stdin); freopen("dmod.out","w",stdout); ll a,b,p; cin>>a>>b>>p; cout<<solve(a,b,p); return 0; }