import java.io.*;
import java.util.*;
public class Main {
public final int max_num = 10000100;
public static void main(String args[]) throws Exception {
new Main().run();
}
void run() {
Calculate();
Scanner cin = new Scanner(System.in);
while (cin.hasNextInt()) {
int a = cin.nextInt();
int b = cin.nextInt();
int max = -1;
for (int i = a; i <= b; ++i) {
if (len[i] > max) {
max = len[i];
}
}
System.out.println(max);
}
}
void Calculate() {
for (int i = 0; i < max_num; ++i) {
len[i] = -1;
}
for (long i = 1; i <= 1000000; ++i) {
int res = GetLen(i);
// System.out.println(i + " : " + res);
}
}
int GetLen(long x) {
// System.out.println("GetLen " + x);
if (x < max_num && len[(int) x] != -1) {
return len[(int) x];
}
if (x == 1) {
len[1] = 1;
return 1;
}
int res = -1;
if (x % 2 == 1) {
res = GetLen(1 + x * 3) + 1;
} else {
res = GetLen(x / 2) + 1;
}
if (x < max_num) {
len[(int) x] = res;
}
return res;
}
int[] len = new int[max_num];
}
沛哥的作品
最新推荐文章于 2024-07-12 09:55:12 发布