找出x,y的范围,枚举就可以了
1 #include <iostream> 2 #include <cstdlib> 3 #include <cstdio> 4 5 using namespace std; 6 7 int main(void) 8 { 9 int k; 10 #ifndef ONLINE_JUDGE 11 freopen("in", "r", stdin); 12 #endif 13 while (~scanf("%d", &k)) 14 { 15 for (int i = k+1; i <= 2*k; ++i) 16 { 17 if ((k*i)/(i-k)%1==0) 18 printf("1/%d = 1/%d + 1/%d\n", k, (k*i)/(i-k), i); 19 } 20 } 21 22 return 0; 23 }