#include<stdio.h>
long long qsortMod(long long a,long long b)
{
long long ans=1;
a%=1000000007;
while(b){
if(b%2==1) ans=ans*a%1000000007;
b/=2;
a=a*a%1000000007;
}
return ans;
}
int main()
{
long long a,b;
while(scanf("%lld%lld",&a,&b)&&!(a==0&&b==0)){
printf("%lld\n",qsortMod(a,b));
}
return 0;
}
快速幂
原文:http://www.cnblogs.com/yzm10/p/7010960.html