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

在线等,为什么wrong了,我实在是搞不定了!

Posted by tw7613781 at 2007-04-20 00:09:56 on Problem 1207
#include<iostream.h>
#include<stdlib.h>
void main()
{
	int n=4;
	int x,y;
	while(n--)
	{	
		int max=1;
		cin>>x>>y;
                   if(x>10000||x<0||y>10000||y<0) exit(1);
                   cout<<x<<' '<<y<<' ';
                   if(x>y) { int temp=y;y=x;x=temp;}
		for(int i=x;i<=y;i++)
		{
			int k=1,s=i;
			while(s!=1)
			{
				if(s%2==1) s=3*s+1;
				else s=s/2;
				k++;
			}
			if(k>max) max=k;
		}
		cout<<max<<endl;
	}
}


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