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

天啊,为什么所有给出的测试数据都过了,而且注意了输出顺序还是wa呢~郁闷

Posted by loveinmysoul at 2009-06-04 20:04:43 on Problem 1207
#include "iostream"
using namespace std;
int main()
{
	int a,b,k,i,max,tmp;
	while(cin>>a>>b)
	{
		if(a<=0||a>1000000||b<=0||b>1000000)  break;
		if(a>b)
		{
			k=b;
			b=a;
			a=k;
		}
		tmp=1;
		for(i=a;i<=b;i++)
		{
			max=1;
			k=i;
			while(k!=1)
			{
				if(k%2)
					k=3*k+1;
				else
					k=k/2;
				max++;
			}
			if(max>tmp)
				tmp=max;
		}
		if(a>b)
			cout<<a<<" "<<b<<" "<<tmp<<endl;
		else
			cout<<b<<" "<<a<<" "<<tmp<<endl;
	}
	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