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 |
为何wrong answer呢 所有数据都能过 哪位牛人帮我看下#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator