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

求救啊!!!测试数据对了,i,j大小和区间断点问题注意,可还是WA

Posted by lin608 at 2010-01-22 00:59:13 on Problem 1207
#include<stdio.h>
void main()
{
	long count,n,i,j,max,m,temp,flag=0;
	scanf("%ld %ld",&i,&j);
	if (i>j) 
	{
		temp=i;
		i=j;
		j=temp;
		flag=1;
	}
	for (n=i;n<=j;n++)
	{
		m=n;
		count=1;
		while (m!=1)
		{
			if (m%2==0) m=m/2;
			else m=3*m+1;
			count++;
		}
		if (count>max) max=count;
	}
	if (flag==1)
		printf("%ld %ld %ld\n",j,i,max);
	else printf("%ld %ld %ld\n",i,j,max);
	
}

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