入门经典 第七章 7.7.3 分数拆分
December 14, 2012
找出x,y的范围,枚举就可以了
#include <iostream>
#include <cstdlib>
#include <cstdio>
using namespace std;
int main(void)
{
int k;
#ifndef ONLINE_JUDGE
freopen("in", "r", stdin);
#endif
while (~scanf("%d", &k))
{
for (int i = k+1; i <= 2*k; ++i)
{
if ((k*i)/(i-k)%1==0)
printf("1/%d = 1/%d + 1/%d\n", k, (k*i)/(i-k), i);
}
}
return 0;
}