​点击打开链接​

看代码吧。。。有注释

import java.math.BigInteger;
import java.util.Scanner;

public class Main {
public static void main(String args[]) {
Scanner sc = new Scanner(System.in);
BigInteger fib[] = new BigInteger[550];//斐波那契数组超过500时,就已经超过100位了
fib[0] = BigInteger.valueOf(1);
fib[1] = BigInteger.valueOf(1);
for (int i = 2; i < 550; i++) {
fib[i] = fib[i - 1].add(fib[i - 2]);
}
while (sc.hasNext()) {
BigInteger a = sc.nextBigInteger();
BigInteger b = sc.nextBigInteger();
if(a.equals(BigInteger.ZERO)&&b.equals(BigInteger.ZERO))//判断a,b是否都为0
{
break;
}
int n = 0;
for (int i = 1; i < 550; i++) {
if (fib[i].compareTo(b) > 0) {
break;
}
if(a.compareTo(fib[i])<=0) {//注意这是<=
n++;
}
}
System.out.println(n);
}
}
}