HDU6063:RXD and math(数论)

题面
题意:

i=1nkμ2(i)nki

1~n的每个数都可以写成 ab2 ,都对应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;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值