Toggle navigation
Home
Latest pastes
FAQ
Random
BitBin is shutting down!
Register
Login
Untitled
SUBMITTED BY:
Guest
DATE:
Dec. 5, 2013, 3:13 p.m.
FORMAT:
Text only
SIZE:
888 Bytes
Raw
Download
Tweet
HITS:
602
Go to comments
Report
#include<iostream>
#include<cstdio>
using namespace std;
int main ()
{
int i, j, t_i, t_j,s;
while(scanf("%d %d", &i, &j)!=EOF )
{
t_i = i;
t_j = j;
if (i>j )
{
s=i;
i=j;
j=s;
}
int max_length = 0;
int cycle_length;
while(i<=j)
{
int n = i;
cycle_length = 1;
while (n!=1)
{
if ((n%2)==1) n = 3 * n + 1;
else n = (n/2);
cycle_length++;
}
if (cycle_length>max_length)
max_length = cycle_length;
i++;
}
printf ("%d %d %d\n", t_i, t_j, max_length);
}
return 0;
}
Please enable JavaScript to view the
comments powered by Disqus.
comments powered by
Disqus