PE 157

哎,开学前最后划一下水,下次泥萌见到窝就是高三狗了TATATATAT

题目大意:求有多少对a<=b满足 1a+1b=p10n ,1 <= n <= 9

PE的难度果真有毒……

设 a = gx,b = gy,g = gcd(a,b)
x+ygxy=p10n
x,y, ggcd(g,x+y) 只能表示成 2i5j 的形式,所以枚举……

诶诶诶,别打啊

【答案】53490

#include <iostream>
#include <cstdio>
#include <map>
#define rep(i,s,t) for (int i = s;i <= t;i ++)
using namespace std;

int pow2[15],pow5[15];
map <int,bool> mp;

void work(int a,int &ret,int i,int j,int lim)
{
    mp.clear();
    for (int d = 1;d * d <= a;d ++)
        if (a % d == 0)
        {
            for (int x = 0;x + i <= lim;x ++)
                for (int y = 0;y + j <= lim;y ++)
                {
                    if (!mp[d * pow2[x] * pow5[y]]) mp[d * pow2[x] * pow5[y]] = 1,ret ++;
                    if (!mp[a / d * pow2[x] * pow5[y]]) mp[a / d * pow2[x] * pow5[y]] = 1,ret ++;
                }
        }
}

int cal(int lim)
{
    int ret = 0;
    rep(i,0,lim) rep(j,0,lim) work(pow2[i] + pow5[j],ret,i,j,lim);
    rep(i,1,lim) rep(j,1,lim) work(pow2[i] * pow5[j] + 1,ret,i,j,lim);
    return ret;
}

int main()
{
    pow2[0] = pow5[0] = 1;
    rep(i,1,10) pow2[i] = pow2[i - 1] * 2,pow5[i] = pow5[i - 1] * 5;
    int ans = 0;
    rep(i,1,9) ans += cal(i);;
    cout << ans << endl;
}
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值