快速幂:P1226
//c/c++ compile run 插件中设置external terminnal,f6运行 #include <iostream> int f(int a,int b,int p){ int res = 1; while(b){ if(b&1)res=res*a%p; a=a*a%p; b>>=1; } return res; } using namespace std; int main(){ cin.tie(0); cin.sync_with_stdio(false); int a,b,p; cin >> a >> b >> p; printf("%d^%d mod %d=%d",a,b,p,f(a,b,p)); return 0; }
标签:return,int,res,cin,数学,a% From: https://www.cnblogs.com/-ark/p/17053351.html