#include <iostream>
#include <stdlib.h>
using namespace std;
int main(){
int i, j;
cin >> i >> j;
int max = 0;
for( int n = i; n<= j ; n++){
int length = 1;
int temp = n;
while( temp != 1){
if( temp % 2 == 1)
temp = 3*temp+1;
else
temp = temp/2;
length++;
}
if( length > max){
max = length;
}
}
cout << max << endl;
system("pause");
return 0;
}
1293. 3n+1数链问题
最新推荐文章于 2017-09-20 13:32:44 发布