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 |
天啊,为什么所有给出的测试数据都过了,而且注意了输出顺序还是wa呢~郁闷#include "iostream" using namespace std; int main() { int a,b,k,i,max,tmp; while(cin>>a>>b) { if(a<=0||a>1000000||b<=0||b>1000000) break; if(a>b) { k=b; b=a; a=k; } tmp=1; for(i=a;i<=b;i++) { max=1; k=i; while(k!=1) { if(k%2) k=3*k+1; else k=k/2; max++; } if(max>tmp) tmp=max; } if(a>b) cout<<a<<" "<<b<<" "<<tmp<<endl; else cout<<b<<" "<<a<<" "<<tmp<<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