Roughly: each number will regress to 1 under this particular operation, resulting in an iterative period number, finding the largest number of periods in the closed interval of the two input numbers.
Note: Count initialization positions; non-operational priority; It is more efficient to use Bit arithmetic n&1?odd:eve
acode:
NULL fun() {
int i , j;
while (~scanf("%d%d",&i,&j)){
int min , max,cont_max=0;
min=i>j?j:i;
max=i>j?i:j;
for (int k = min; k <= max; ++k) {
int num=k;
int cont=1;
while (num!=1){
if(!(num%2)) num/=2;
else num=num*3+1; //(num&1)
cont++;
}
cont_max=cont>cont_max?cont:cont_max;
}
printf("%d %d %d\n",i,j,cont_max);
}
}