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

为何wrong answer呢 所有数据都能过 哪位牛人帮我看下

Posted by 810974380 at 2009-04-15 15:25:35 on Problem 1207
#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;
   while(cin>>p>>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<<p<<" "<<q<<" "<<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