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

1207在下面运行对交上去怎么老是错呢,哪位高手指点一下

Posted by 15269395708 at 2010-01-12 20:50:56
#include<stdio.h>
int main()
{
	int m,n,s,i,t,max,p;
	while(scanf("%d%d",&m,&n)!=EOF)
	{
		p=m;t=1;
		while(p!=1)
		{ 
			if((p%2)==0)p=p/2;
			  else p=3*p+1;
			  t++;
		}
		s=t;
	    for(i=m+1;i<=n;i++)
		{
		   t=1;p=i;
		   while(p!=1)
		   {
			  if((p%2)==0)p=p/2;
			  else p=3*p+1;
			   t++;
		   }
		   if(s<t)s=t;
		}

		printf("%d %d %d\n",m,n,s);
	}
	return 0;
}

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