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 |
把你代码改了一下就过了 orz你的方法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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator