正题
题目链接:https://www.luogu.org/problem/P5253
题目大意
给一个nnn,求有多少对x,y(x≤y)x,y(x\leq y)x,y(x≤y)使得
1x+1y=1n\frac{1}{x}+\frac{1}{y}=\frac{1}{n}x1+y1=n1
解题思路
x+yxy=1n\frac{x+y}{xy}=\frac{1}{n}xyx+y=n1
n(x+y)=xyn(x+y)=xyn(x+y)=xy
xy−n(x+y)=0xy-n(x+y)=0xy−n(x+y)=0
xy−n(x+y)+n2=n2xy-n(x+y)+n^2=n^2xy−n(x+y)+n2=n2
(x−n)(y−n)=n2(x-n)(y-n)=n^2(x−n)(y−n)=n2
设a=x−n,b=y−na=x-n,b=y-na=x−n,b=y−n,问题就变为了求有多少对(a,b)(a,b)(a,b)
然后对于∑pici=n\sum p_i^{c_i}=n∑pici=n
答案就是∏(2∗ci)\prod (2*c_i)∏(2∗ci)
注意要考虑本质不同
codecodecode
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
ll n,ans=1;
int main()
{scanf("%lld",&n);for(ll i=2;i*i<=n;i++){if(!(n%i)){int z=0;while(!(n%i)) n/=i,z++;ans*=2*z+1;}}if(n!=1) ans*=3; printf("%lld",ans/2+(ans&1));
}