快速幂模版
#include<bits/stdc++.h> using namespace std; const int N=1e5+5,INF=0x3f3f3f3f; typedef long long LL; LL a,b,p; LL power(){ LL ans=1; while(b){ if(b&1)ans = ans*a%p; b>>=1; a = a*a%p; } return ans%p; } int main() { cin>>a>>b>>p; cout<<power(); return 0; }
注册一个 TeMenHu 通用账户,您就可以在我们提供的所有在线评测服务上提交代码、参与讨论。
使用您的 TeMenHu 通用账户