【题目链接】 http://acm.hdu.edu.cn/showproblem.php?pid=6063
题目意思
公式题:不弄题目了。
解题思路
考莫比乌斯函数,最终答案等于n^k取模,用整数快速幂跑。
代码部分
#include <bits/stdc++.h>
using namespace std;
const int N =
1e6+
7;
typedef long long ll;
const ll mod =
1e9+
7;
int main()
{
ll n,k,i=
0;
while (
scanf(
"%lld %lld",&n,&k)!=EOF)
{
ll ans=
1,red=n;
while (k)
{
if(k&
1)
ans=((ans%mod)*(red%mod))%mod;
red=((red%mod)*(red%mod))%mod;
k=k>>
1;
}
printf(
"Case #%lld: %lld\n",++i,ans);
}
return 0;
}