Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 10 Accepted Submission(s) : 6
Font: Times New Roman | Verdana | Georgia
Font Size: ← →
Problem Description
Input
Output
Sample Input
Sample Output
Author
Source
include<stdio.h>
int main()
{ int n,a[100],m,i,t,k;
while(scanf("%d",&n)!=EOF)
{
while(n--)
{ scanf("%d",&m);
k=t=0;
for(i=0;i<100;i++)
a[i]=0;
while(1)
{ if(m%2==1)
{ a[k++]=m;
m=m*3+1;
t++;
}
else if(m%2==0)
{ m/=2;
}
if(m==1)
break;
}
if(t==0) printf("No number can be output !\n");
else for(i=0;i<k;i++)
printf("%d%c",a[i],i!=k-1?' ':'\n');
}
}
return 0;
}