您的位置:首页 > 其它

HDU6063:RXD and math(数论)

2018-01-19 11:11 429 查看
题面

题意:

∑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;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: