#include
//对a/b,b/a的倒数是最接近a/b的了
//令c=b/a+1;则 a/b = 1/c + x;
//求出x的分数形式,递归求解即可:x的分子等于ac-b;分母等于bc
void solve(int a, int b)
{
int c,tb;
printf("%d/%d=",a,b);
while(1)
{
if(b%a==0)
break;
c=b/a+1;
a=a*c-b;
b=b*c;
printf("1/%d+",c);
}
printf("1/%d\n",b/a);
}
main()
{
int a,b;
scanf("%d%d",&a,&b);
if(a solve(a,b);
return 0;
}
阅读(649) | 评论(0) | 转发(0) |