#pragma GCC optimize(2) #pragma GCC optimize(3,"Ofast","inline") #include<iostream> #include<cstdio> #include<cstring> #include<queue> #include<algorithm> #include<map> #include<cmath> typedef long long ll; using namespace std; ll qmi(ll a,ll b,ll c) { ll res=1; while(b)//统计次方状态 { if(b&1) res=res*a%c;//(判断是否是奇数,并且对res*a) a=a*a%c;//(a*自生) b/=2;//( 阶乘/2) } return res; } int main() { ll a,b,c; cin>>a>>b>>c; cout<<a<<'^'<<b<<' '<<"mod"<<' '<<c<<'='<<qmi(a,b,c); }