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:全部测试数据In Reply To:Re:全部测试数据 Posted by:mingzhizhuo at 2009-04-02 18:41:19 我的也都通过了,为什么还是不行额...帮忙看看~谢啦~ #include <iostream> using namespace std; int main() { int getnum(int s); int m,n,q; while (scanf("%d%d",&m,&n)!=EOF) { if(m>n) { q=m; m=n; n=q; } int maxnum=getnum(m); printf("%d %d",m,n); for(int t=m+1;t<=n;t++) { if(maxnum<getnum(t)) maxnum=getnum(t); } cout<<" "<<maxnum<<endl; } return 0; } int getnum(int s) { int num=0; for(int p=s;p!=1;) { if(p%2==1) p=3*p+1; else p/=2; num++; } return (++num); } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator