UVA - 10976 Fractions Again?!

#include<bits/stdc++.h>
using namespace std;

typedef pair<int,int>Pair;

int main()
{
    int k;
    while(cin >> k){
        int cnt = 0;
        vector<Pair>ans;
        for(int y = k + 1; y <= 2*k; y++){
            if(y*k % (y - k) == 0){
                cnt++;
                ans.push_back(make_pair(k, y));
            }
        }
        cout << ans.size() << endl;
        for(auto item : ans){
            int k = item.first, y = item.second;
            printf("1/%d = 1/%d + 1/%d\n", k, y*k / (y-k), y);
        }
    }
    return 0;
}

 

posted on 2019-02-27 20:58  nbsanshi  阅读(74)  评论(0)    收藏  举报

导航