| ||||||||||
| 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 | |||||||||
Re:Help me 老是wrong answer 啊,那位高手帮我看看把In Reply To:Help me 老是wrong answer 啊,那位高手帮我看看把 Posted by:clean at 2005-04-26 14:33:21 > #include<iostream>
> using namespace std;
> int length(int x);
> int main()
> {
> long i,j,tem;
> int max;
> while(cin>>i>>j)
> {
> if(i!=0&&j!=0)
> 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