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

把你代码改了一下就过了 orz你的方法

Posted by 980616701 at 2009-06-24 19:27:26 on Problem 1207
In Reply To:为何wrong answer呢 所有数据都能过 哪位牛人帮我看下 Posted by:810974380 at 2009-04-15 15:25:35
#include<iostream>
using namespace std;
int swap(int &m,int &n)
{   int temp;
    if(m>n) {temp=m;m=n;n=temp;}
    return 0;
}
int main()
{
   int p,q,n,i,p1,p2;
   while(cin>>p>>q)
   {
	   p1=p;p2=q;
	   swap(p,q);int max=0;
      for(i=p;i<=q;i++)
	  { 
			 int t=0;
			for(n=i;n>=1;)
			{ if(n==1) {t++;break;}
			else if(n%2==0)
			{ t++;n=n/2;}
			else {t++;n=3*n+1;}
      }
			 if(t>max) max=t;
     }
   cout<<p1<<" "<<p2<<" "<<max<<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