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

Re:全部测试数据

Posted by Lenus at 2010-08-08 18:46:12 on Problem 1207
In Reply To:Re:全部测试数据 Posted by:420625383 at 2009-04-18 18:36:21
m和n交换大小后,输出就变了。

> 我的也都通过了,为什么还是不行额...帮忙看看~谢啦~
> #include <iostream>
> using namespace std;
> int main()
> {
> 	int getnum(int s);
> 	int m,n,q;
> 	while (scanf("%d%d",&m,&n)!=EOF)
> 	{
> 		if(m>n)
> 		{
> 			q=m;
> 			m=n;
> 			n=q;
> 		}
> 	int maxnum=getnum(m);
> 	printf("%d %d",m,n);
> 	for(int t=m+1;t<=n;t++)
> 	{
> 		if(maxnum<getnum(t))
> 			maxnum=getnum(t);
> 	}
> 	cout<<" "<<maxnum<<endl;
> 	}
> 	return 0;
> }
> int getnum(int s)
> {
> 	int num=0;
> 	for(int p=s;p!=1;)
> 	{
> 		if(p%2==1)
> 			p=3*p+1;
> 		else p/=2;
> 		num++;
> 	}
> 	return (++num);
> }

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