Skip to content
Permalink
535f8e27c5
Switch branches/tags

Name already in use

A tag already exists with the provided branch name. Many Git commands accept both tag and branch names, so creating this branch may cause unexpected behavior. Are you sure you want to create this branch?
Go to file
 
 
Cannot retrieve contributors at this time
31 lines (26 sloc) 432 Bytes
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
int i, j;
while (cin >> i >> j)
{
long long total = 0,
op = 0;
int m = min (i, j);
int M = max (i, j);
for (int x = m; x <= M; ++x)
{
op = 1;
for (int n = x; n != 1; ++op)
if (n % 2)
n = n * 3 + 1;
else
n /= 2;
if (total < op) total = op;
}
cout << i << ' ' << j << ' ' << total << endl;
}
return 0;
}