Fractional Split time limit:MS | Memory limit:65535 KB Difficulty:1
-
Describe
-
Now enter a positive integer k to find all positive integer x>=y, making 1/k=1/x+1/y.
-
Input
-
The first line enters an integer n, which indicates that there are n sets of test data.
Next n lines enter a positive integer k per line
-
Output
-
sequentially output the corresponding k for each row to find all the combinations that meet the criteria 1/k=1/x+1/y
-
Sample input
-
22 12
-
Sample output
-
1/2=1/6+1/31/2=1/4+1/41/12=1/156+1/131/12=1/84+1/141/12=1/60+1/151/12=1/48+1/161/12=1/36+1/181/12=1/30+1/201/ 12=1/28+1/211/12=1/24+1/24
1#include <iostream>2 using namespacestd;3 intMain ()4 {5 intn,k,x,y;6Cin>>N;7 while(n--)8 {9Cin>>K;Ten for(y=k+1; y<=2*k;y++) One { A if((k*y)% (y-k) = =0) - { -x= (k*y)/(Yk); thecout<<"1/"<<k<<"=1/"<<x<<"+1/"<<y<<Endl; - } - } - + } - return 0; +}
Nyoj 66 Fractional Split