现在输入一个正整数k,找到所有的正整数x>=y,使得1/k=1/x+1/y.
样例输入:
2
样例输出:
1/2=1/6+1/3
1/2=1/4+1/4
#include<stdio.h>
int main()
{
int k, x, y;
while (scanf("%d", &k) == 1)
{
for (y = k + 1; y <= 2 * k; y++)
{
x = k * y / (y - k);
if (k * y % (y - k) == 0 && x >= y)
{
printf("1 / %2d = 1 / %2d + 1 / %2d\n", k, x, y);
}
}
}
return 0;
}