1 10100 200201 210900 1000 Sample Output1 10 20100 200 125201 210 89900 1000 174#include<iostream>using namespace std;int main(){ int a1,b1,i; while(cin>>a1>>b1) { int a=a1,b=b1; if(a1>b1) { a=b1;b=a1;} int max=-1,sum,n; for(i=a;i<=b;i++) { n=i; sum=1; while(n!=1) { if(n%2!=0) n=3*n+1; else n=n/2; sum++; } if(max<sum) max=sum; //cout<<max<<" "; } cout<<a1<<" "<<b1<<" "<<max<<endl; } }
新闻热点
疑难解答