首页 > 代码库 > rwkj 1394 分数拆分
rwkj 1394 分数拆分
#include<stdio.h>
main()
{
int k,x,y,n;
scanf("%d",&n);
while(n--)
{
scanf("%d",&k);
for(x=k+1;x<=2*k;x++)
for(y=2*k;;y++)
{
if(x*y>k*(x+y))break;
if(x*y==k*(x+y)) printf("1/%d=1/%d+1/%d\n",k,y,x);
}
}
}
#include <iostream.h>
int main()
{
int k,x,y,i,n;
cin>>n;
for (i=0;i<n;i++)
{
cin>>k;
for (y=k+1;y<=2*k;y++)
if ((k*y)%(y-k)==0)
{
x=k*y/(y-k);
cout<<"1/"<<k<<"="<<"1/"<<x<<"+"<<"1/"<<y<<endl;
}
}
}
//1394
#include <iostream.h>
int main()
{
int k,x,y,n;
cin>>n;
while(n--)
{
cin>>k;
for (y=k+1;y<=2*k;y++)
if ((k*y)%(y-k)==0)
{
x=k*y/(y-k);
cout<<"1/"<<k<<"="<<"1/"<<x<<"+"<<"1/"<<y<<endl;
}
}
}
#include<stdio.h>
int main()
{
int k,n,x,y;
scanf("%d",&n);
while(n--)
{
scanf("%d",&k);
for(y=k+1;y<=2*k;y++)
if(k*y%(y-k)==0)
{
x=k*y/(y-k);
printf("1/%d=1/%d+1/%d\n",k,x,y);
}
}
}
#include<stdio.h>
int main()
{int k,n,y;
scanf("%d",&n);
while(n--)
{
scanf("%d",&k);
for(y=k+1;y<=2*k;++y)
if(k*y%(y-k)==0)
printf("1/%d=1/%d+1/%d\n",k,k*y/(y-k),y);
}
}