标签:
1 #include<stdio.h>//次方求模(102) 2 long long power(int a,int b,int c) 3 { 4 long long t; 5 if(b==0)return 1%c; 6 if(b==1)return a%c; 7 t=power(a,b/2,c); 8 t=t*t%c; 9 if(b&1)return t*a%c; 10 else return t; 11 } 12 int main() 13 { 14 int x; 15 long long a,b,c; 16 scanf("%d",&x); 17 while(x--){ 18 scanf("%lld%lld%lld",&a,&b,&c); 19 printf("%lld\n",power(a,b,c)); 20 } 21 return 0; 22 }
标签:
原文地址:http://www.cnblogs.com/minimalism/p/4537615.html