Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
怎么老是wrong answer 啊#include<iostream> using namespace std; int length(int x); int main() { long i,j,tem; int max; while(cin>>i>>j) { cout<<i<<" "<<j<<" "; if(i>j) { tem=i; j=tem; i=j; } max=0; for(int m=i;m<=j;m++) { if(max<length(m)) max=length(m); } cout<<max<<endl; } return 0; } int length(int x) { int count=0; count=0; while(x!=1) { count++; if((x%2)==0)x=x/2; else x=(3*x+1) ; } return count+1; } Followed by:
Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator