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

为什么我的程序不能达到0MS?

Posted by aisac at 2007-12-09 16:45:04 on Problem 1207
#include <iostream>
using namespace std;
int main()
{
	int   temp1, temp2;
	while ( cin >> temp1 >> temp2)
	{
		int big = 0;
		int first = temp1 <= temp2 ? temp1 : temp2;
		int second = temp1 > temp2 ? temp1 : temp2;
		for (int i=first; i<=second; ++i)
		{
			int temp = i;
			int cnt = 1;
			while ( temp != 1)
			{
				++cnt;
				if ( temp%2 == 0 )
					temp = temp >> 1;
				else
					temp = temp + (temp << 1) + 1;
			}
			if (cnt > big)
				big = cnt;
		}
		cout << temp1 << " " << temp2 << " " << big << 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