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

为什么会有OLE ,第二次就好了,真是无语

Posted by ZHG177 at 2017-05-05 03:40:44 on Problem 1207
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstdio>

using namespace std;
int caculate(int num)
{
	int no=1;
	if(num==1)
		return no;
	else 
	{
		while(num!=1)
		{
			if(num%2==0)
				num/=2;
			else
				num=num*3+1;
			no++;
		}
	}
	return no;
}
int main(int argc, char const *argv[])
{
	int m,n;
	while(cin>>m>>n)
	{
		int tM=m,tN=n;
		if(m>n)
		{
			int t=m;
			m=n;
			n=t;
		}
		int maxn=0;
		for(int i=m;i<=n;i++)
			maxn=max(maxn,caculate(i));
		cout<<tM<<" "<<tN<<" "<<maxn<<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