队友看输出看出了规律。。。答案就是n的k次方取模。。。
这是为什么啊?
#include<cstdio>
const int mod = 1000000007;
long long PowerMod(long long a, long long b, long long c)
{
long long ans = 1;
a = a % c;
while(b>0)
{
if(b % 2 == 1)
ans = (ans * a) % c;
b = b/2;
a = (a * a) % c;
}
return ans;
}
int main()
{
int t = 1;
long long n,k;
while(scanf("%I64d%I64d",&n,&k)!=EOF)
{
printf("Case #%d: %I64d\n",t++,PowerMod(n,k,mod));
}
return 0;
}