标签:
3个正整数A B C,中间用空格分隔。(1 <= A,B,C <= 10^9)
输出计算结果
3 5 8
3
1 #include<iostream> 2 #include<cstdio> 3 #include<cstring> 4 #include<algorithm> 5 #define ll long long 6 using namespace std; 7 8 ll pow(ll x,ll n,ll m){ 9 ll ans=1; 10 while(n){ 11 if(n&1)ans=ans*x%m; 12 x=(x*x)%m; 13 n>>=1; 14 } 15 return ans; 16 } 17 18 int main(){ 19 ll a,b,c; 20 scanf("%lld%lld%lld",&a,&b,&c); 21 printf("%lld\n",pow(a,b,c)); 22 return 0; 23 }
51Nod 1046 A^B Mod C Label:快速幂
标签:
原文地址:http://www.cnblogs.com/radiumlrb/p/5929142.html