分析:x>=y故1/y>=1/x,1/k-1/y<=1/y,所以可知道y<=2k,然后通过y去求解x即可
1 #include "iostream" 2 #include "cstdio" 3 #include "cstring" 4 #include "vector" 5 using namespace std; 6 int k; 7 int main() 8 { 9 while(cin>>k) 10 { 11 vector<int> que1,que2; 12 for(int i=k+1;i<=(2*k);i++){ 13 if(i*k%(i-k)==0){ 14 que1.push_back(i); 15 que2.push_back(i*k/(i-k)); 16 } 17 } 18 int t=que1.size(); 19 printf("%d ",t); 20 for(int i=0;i<que1.size();i++){ 21 printf("1/%d = 1/%d + 1/%d ",k,que2[i],que1[i]); 22 } 23 } 24 }