| ||||||||||
| Online Judge | Problem Set | Authors | Online Contests | User | ||||||
|---|---|---|---|---|---|---|---|---|---|---|
| Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest | |||||||||
Re:能看一下错在那里吗?结果是对的为什么提交是wrong answerIn Reply To:能看一下错在那里吗?结果是对的为什么提交是wrong answer Posted by:cherubicwing at 2006-07-08 08:42:05 > #include"iostream"
> using namespace std;
> int main()
> {
> int a,b;
> int boo=0;
> while(cin>>a>>b)
> {
> if(a<=0||a>1000000||b<=0||b>1000000) break;
> if(a>b)
> {
> int tem=a;
> a=b;
> b=tem;
> boo=1;
> }
> int max,max2,num;
> max=max2=1;
> for(int i=a;i<b;i++)//这里应该是i<=b;
> {
> num=i;
> while(num!=1)
> {
> if(num%2!=0) num=3*num+1;
> else
> num=num/2;
> max++;
> }
> if(max2<max) max2=max;
> max=1;
> }
> if(boo==1)
> cout<<b<<" "<<a<<" "<<max2<<endl;
> else
> cout<<a<<" "<<b<<" "<<max2<<endl;
> boo=0;//加上
> }
> return 0;
> }
Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator