#include<bits/stdc++.h>
int cycle(int x);
using namespace std;
int main()
{
int i , j, cy,high=0;
while(cin>>i>>j){
cout<<i<<" "<<j<<" ";
if(i>j)
swap(i,j);
for(int m=i; m<=j; m++){
cy=cycle(m);
if(cy>high)
high=cy;
}
cout<<high<<endl;
high=0;
}
return 0;
}
int cycle(int x)
{
int num,cnt=0;
num=x;
while(1){
cnt++;
if(num==1)
break;
else{
if(num%2==0)
num/=2;
else
num=(num*3)+1;
}
}
return cnt;
}
int cycle(int x);
using namespace std;
int main()
{
int i , j, cy,high=0;
while(cin>>i>>j){
cout<<i<<" "<<j<<" ";
if(i>j)
swap(i,j);
for(int m=i; m<=j; m++){
cy=cycle(m);
if(cy>high)
high=cy;
}
cout<<high<<endl;
high=0;
}
return 0;
}
int cycle(int x)
{
int num,cnt=0;
num=x;
while(1){
cnt++;
if(num==1)
break;
else{
if(num%2==0)
num/=2;
else
num=(num*3)+1;
}
}
return cnt;
}
No comments:
Post a Comment