【模板】快速幂取模
快速幂取模的模板,要注意所有变量都要开成long long类型的防溢出:
![](https://images.cnblogs.com/OutliningIndicators/ContractedBlock.gif)
#include<cstdio> #include<algorithm> #include<cstring> typedef long long LL; const LL mod=1e9+7; using namespace std; LL a,b; LL mi(LL x,LL y) { LL res=1; while(y){ if(y&1) res=res*x%mod; y>>=1; x=x*x%mod; } return res; } int main() { scanf("%lld %lld",&a,&b);//ÇóaµÄb´ÎÃÝ printf("%lld",mi(a,b)); return 0; }