题面
题意:
∑i=1nkμ2(i)∗nki−−−√
1~n的每个数都可以写成
a∗b2
,都对应1个a。a无平方因子。
循环就相当于枚举a,剩下的是算出有多少个b。
没问题,妥妥的。
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <cstdlib>
#include <cstring>
using namespace std;
#define mmst(a, b) memset(a, b, sizeof(a))
#define mmcp(a, b) memcpy(a, b, sizeof(b))
typedef long long LL;
const LL mo=1e9+7;
LL jia(LL a,LL b)
{
LL res=0;
for(;b;b>>=1,a=(a+a)%mo)
if(b&1)
res=(res+a)%mo;
return res;
}
LL cheng(LL a,LL b)
{
LL res=1;
for(;b;b>>=1,a=jia(a,a))
if(b&1)
res=jia(res,a);
return res;
}
LL n,k,tu=1;
int main()
{
while(~scanf("%lld%lld",&n,&k))
{
printf("Case #%lld: %lld\n",tu,cheng(n,k));
tu++;
}
return 0;
}