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 |
果断中招#include<iostream> using namespace std; int cal(int n){ int count=0; while(n!=1){ count++; if(n%2==0)n=n/2; else n=3*n+1; } count++; return count; } int main (){ int a,b; while(scanf("%d%d",&a,&b)!=EOF){ int max=0; bool flag=true; if(a>b){ int c=b; b=a; a=c; flag=false; } for(int i=a;i<=b;i++){ if(cal(i)>max)max=cal(i); } if(flag) cout<<a<<" "<<b<<" "<<max<<endl; else cout<<b<<" "<<a<<" "<<max<<endl; } //system("pause"); return 0; } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator