标签:
现在输入一个正整数k,找到所有的正整数x>=y,使得1/k=1/x+1/y.
2 2 12
1/2=1/6+1/3 1/2=1/4+1/4 1/12=1/156+1/13 1/12=1/84+1/14 1/12=1/60+1/15 1/12=1/48+1/16 1/12=1/36+1/18 1/12=1/30+1/20 1/12=1/28+1/21 1/12=1/24+1/24
1 #include<iostream> 2 using namespace std; 3 int main() 4 { 5 int N,k,x,y; 6 cin>>N; 7 while(N--) 8 { 9 cin>>k; 10 for(y=k+1;y<=2*k;y++) 11 { 12 if((k*y)%(y-k)==0) 13 { 14 x=(k*y)/(y-k); 15 cout<<"1/"<<k<<"=1/"<<x<<"+1/"<<y<<endl; 16 } 17 } 18 19 } 20 return 0; 21 }
标签:
原文地址:http://www.cnblogs.com/ljwTiey/p/4305468.html