1. 程式人生 > >Fractions Again?! (UVA - 10976)

Fractions Again?! (UVA - 10976)

actions stdio.h () urn uva sin ++ ans stream

#include<stdio.h>
#include<iostream>
using namespace std;
int main()
{
int k,x,y,ans;
while(cin>>k&&k!=0)
{
ans=0;
for(int y=k+1;y<=k<<1;y++)
{
x=(k*y)/(y-k);
if((k*y)%(y-k)==0&&x>=y)
{
ans++;
}
}
printf("%d\n",ans);
for(int y=k+1;y<=k<<1;y++)

{
x=(k*y)/(y-k);
if((k*y)%(y-k)==0&&x>=y)
{
printf("1/%d = 1/%d + 1/%d\n",k,x,y);
}
}

}
return 0;
}

Fractions Again?! (UVA - 10976)