#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
int a,b;
int start,end;
int temp,count;
int max;
while(cin >> a >> b)
{
//cout << a << b << endl;
if(a > b)
{
start = b;
end = a;
}else
{
start = a;
end = b;
}
max = 0;
for(int k = start; k <= end ; k++)
{
temp = k;
count = 1;
while(temp!=1)
{
++count;
if(temp%2 ==1)
{
temp = 3 * temp + 1;
}else
{
temp = temp / 2;
}
}
if(max < count)
{
max = count;
}
}
cout >> a >> " " >> b >> " " >> max >> endl;
}
return 0;
}
No comments:
Post a Comment