Java水了。
import java.util.Scanner;
import java.math.BigInteger; public class Main {
public static void main(String[] args) {
Scanner cin = new Scanner(System.in);
BigInteger[] fibs = new BigInteger[MAXN];
// init the fibs
fibs[0] = BigInteger.valueOf(1);
fibs[1] = BigInteger.valueOf(2);
int n = 2;
while (true) {
fibs[n] = fibs[n-1].add(fibs[n-2]);
++n;
if (fibs[n-1].toString().length() >= 101)
break;
}
// System.out.println(n);
while (cin.hasNext()) {
BigInteger aa = cin.nextBigInteger();
BigInteger bb = cin.nextBigInteger();
if (aa.compareTo(BigInteger.ZERO)==0 && bb.compareTo(BigInteger.ZERO)==0) {
break;
}
int ans = 0;
for (int i=0; i<n; ++i) {
if (fibs[i].compareTo(aa) >= 0) {
if (fibs[i].compareTo(bb) <= 0)
++ans;
else
break;
}
}
System.out.println(ans);
}
} public static final int MAXN = 505;
}