视频链接:
#include <iostream> using namespace std; typedef long long LL; int a, b, p; int quickpow(int a, int b, int p){ int res = 1; while(b){ if(b&1) res = (LL)res*a%p; a = (LL)a*a%p; b >>= 1; } return res; } int main(){ cin >> a >> b >> p; int s = quickpow(a, b, p); printf("%d^%d mod %d=%d\n",a,b,p,s); return 0; }
标签:a%,int,res,LL,long,quickpow,506,快速 From: https://www.cnblogs.com/dx123/p/16656036.html