Nyoj 66 Fractional Split

Source: Internet
Author: User

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

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.