Description Input 多组用例,每组用例输入两个整数n和k,以文件尾结束输入(T<=10000,1<=n,k<=1e18) Output 对于每组用例,输出答案 Sample Input 10 10 Sample Output Case #1: 999999937 Solution Code
using namespace std;
typedef long long ll;
int mod_pow(
int a,
int b,
int mod)
{
int ans=
1;
while(b)
{
if(b&
1)ans=(ll)ans
*a%mod;
a=(ll)a
*a%mod;
b>>=
1;
}
return ans;
}
int main()
{
int Case=
1;
ll n,k;
while(~scanf(
"%I64d%I64d",&n,&k))
{
n
%=Mod,k
%=(Mod-
1);
printf(
"Case #%d: %d\n",Case++,mod_pow(n,k,Mod));
}
}