标签:std style scan bit ++ nbsp font family pac
#include<bits/stdc++.h> using namespace std; long long a,b,p; int main() { scanf("%lld%lld%lld",&a,&b,&p); long long ans=0; for(;b;b>>=1)//‘b‘每次除2 { if(b&1)//‘b‘是否为偶数
ans=(ans+a)%p; a=(a*2)%p; } printf("%lld",(ans%p)); return 0; }
#include<bits/stdc++.h> using namespace std; long long a,b,p; int main() { scanf("%lld%lld%lld",&a,&b,&p); long long ans=1; for(;b;b>>=1) { if(b&1) ans=(ans*a)%p; a=(a*a)%p; } printf("%lld",(ans%p)); return 0; }
标签:std style scan bit ++ nbsp font family pac
原文地址:https://www.cnblogs.com/HHHG/p/11106510.html