Fractions Again?! UVA

来源:互联网 发布:直通网络测试仪怎么用 编辑:程序博客网 时间:2024/06/15 08:20

问题类型:暴力枚举,分数

问题链接
03pie’s solution for [UVA-10976] :

#include<bits/stdc++.h>//包含所有头文件using namespace std;typedef long long LL;const double PI=acos(-1.0);const int maxn=10000+5;int a[maxn],b[maxn];int main(){    freopen("F://inp.txt","r",stdin);    freopen("F://outp.txt","w",stdout);    int n;    while(~scanf("%d",&n)){        int k=n<<1,count=0;        for(int i=n+1;i<=k;i++){            if(n*i%(i-n)==0){                a[count]=n*i/(i-n),b[count]=i;                count++;            }        }        printf("%d\n",count);          for (int i = 0 ; i < count ; ++ i)              printf("1/%d = 1/%d + 1/%d\n",n,a[i],b[i]);      }    return 0;}
0 0
原创粉丝点击