UVA 10976(暴力)

UVA 10976
题意:输入正整数k,找到所有的正整数x>=y,使得1/k=1/x+1/y。

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct node{
    ll a, b, c;
};
ll n, cnt;
int main(){
    #ifdef ONLINE_JUDGE
    #else
        freopen("in.txt", "r", stdin);
    #endif // ONLINE_JUDGE
    while(~scanf("%lld", &n)){
        cnt = 0;
        vector<node> Q;
        for(ll i = n + 1; i <= 2 * n; i++){
            ll t = n * i;
            if(t % (i - n) == 0){
                Q.push_back((node){n, t / (i - n), i});
                cnt++;
            }
        }
        printf("%d\n", cnt);
        for(int i = 0; i < Q.size(); i++){
            printf("1/%d = 1/%d + 1/%d\n", Q[i].a, Q[i].b, Q[i].c);
        }
    }
    return 0;
}

posted on 2019-01-04 16:34  坤sir  阅读(143)  评论(0编辑  收藏  举报

导航