当前位置: 代码迷 >> 综合 >> Fractions Again?! UVA - 10976
  详细解决方案

Fractions Again?! UVA - 10976

热度:79   发布时间:2023-10-13 14:17:06.0

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

问题链接
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;
}