标签:
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/32768 K (Java/Others)
Total Submission(s): 7196 Accepted Submission(s):
3700
1 #include <iostream> 2 using namespace std; 3 int main() 4 { 5 int N; 6 cin>>N; 7 while(N--) 8 { 9 int num; 10 int a[10000]={0},i,j=0; 11 cin>>num; 12 while(num!=1) 13 { 14 if(num%2==1) 15 { 16 a[j++]=num; 17 num=num*3+1; 18 } 19 else 20 num=num/2; 21 } 22 if(!j) 23 cout<<"No number can be output !"<<endl; 24 else 25 { 26 for(i=0;i<j-1;i++) 27 cout<<a[i]<<‘ ‘; 28 cout<<a[j-1]<<endl; 29 } 30 } 31 }
标签:
原文地址:http://www.cnblogs.com/a1225234/p/4603360.html