哎,开学前最后划一下水,下次泥萌见到窝就是高三狗了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;
}