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:把你代码改了一下就过了 orz你的方法In Reply To:把你代码改了一下就过了 orz你的方法 Posted by:980616701 at 2009-06-24 19:27:26 > #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