欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页

Fractions Again?! UVA - 10976

程序员文章站 2022-06-08 12:30:35
...

题目链接:Fractions Again?! UVA - 10976

题目:
Fractions Again?! UVA - 10976
ac代码:

#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<queue>
#include<stack>
#include<map>
#include<iomanip>
#define ll long long

using namespace std;
const int maxn = 99999 + 5;
int k;

void FIND() {
    int x,y;
    int sum = 0;
    for(int i= k+1; i <= 2*k; i++) {
        if((k*i)%(i - k) == 0) {
            sum ++;
        }
    }
    printf("%d\n",sum);
    for(int i= k+1; i <= 2*k; i++) {
        if((k*i)%(i - k) == 0) {
            sum ++;
            y = i; x = (k*i)/(i - k);
            if(x<y) swap(x,y);
            printf("1/%d = 1/%d + 1/%d\n",k,x,y);
        }
    }
}



int main() {
    int x,y;
    while(scanf("%d",&k) != EOF) {
        FIND();
    }
    return 0;
}