分数拆分

在这里插入图片描述
.
.
.
.
.
分析

	1/k=1/x+y/1

对于x、y这两个未知数,我们尝试把y消掉
经过一番折腾, 我们得出:

	(x-n)/nx=1/y

	nx/(x-n)=y

对于答案来说,若nx能整除(x-n),则ans+1


接下来考虑x的范围

由 nx/(x-n)=y/1
可得
x-n>=1
x >=x+1

其次 x>=y
可得
nx/(x-n)>=x
nx>=x(x-n)
n>=x-n
n+n>=x
得:x<=2n

综上,n+1<=x<=2n

.
.
.
.
.
.
程序:

#include<iostream>
#include<cstdio>
using namespace std;
int main()
{
	int ans=0,k;
	scanf("%d",&k);
	for (int x=k+1;x<=2*k;x++)
		if ((k*x)%(x-k)==0) ans++;
	printf("%d",ans);
	return 0;
}
原文地址:https://www.cnblogs.com/YYC-0304/p/10292830.html