比赛 位运算及及其应用题单 评测结果 AAAAAAAAAA
题目名称 取余运算 最终得分 100
用户昵称 zqy 运行时间 0.030 s
代码语言 C++ 内存使用 3.30 MiB
提交时间 2025-01-25 11:22:14
显示代码纯文本
#include <iostream>
using namespace std;
typedef long long ll;
ll ksm(ll a,ll b,ll mod){
    ll ans=1;
    while(b){
        if(b&1)ans=(ans*a)%mod;
        a=(a*a)%mod;
        b>>=1;
    }
    return ans;
}
int main(){
    freopen("dmod.in","r",stdin);
    freopen("dmod.out","w",stdout);
    ll a,b,p;
    cin>>a>>b>>p;
    cout<<ksm(a,b,p)<<endl;
    return 0;
}