Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

Re:Help me 老是wrong answer 啊,那位高手帮我看看把

Posted by clean at 2005-04-26 14:34:47 on Problem 1207
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator