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
北京大学《ACM/ICPC大学生程序设计竞赛训练》暑期课面向全球招生!

这样做是好的!

Posted by chenxuan123456789 at 2012-07-31 08:37:23 on Problem 1207
#include <stdio.h>
int main()
{
	int a,b,temp,ka,kb,count,k,m,max;
	while(scanf("%d%d",&a,&b)!=EOF)
	{
		printf("%d %d ",a,b);
		if(a>b)
		{
			temp=a;
			a=b;
			b=temp;
		}
		max=0;
		for(k=a;k<=b;k++)
		{
			m=k;
			count=1;
			while(m!=1)
			{
				if(m%2)
					m=3*m+1;
				else
					m/=2;
				count++;
			}
			if(count>max)
			max=count;
		}
		printf("%d\n",max);
	}
	return 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