刚看题目,想不明白要怎么做,似乎除了暴力没什么特别好的方法。然后算了一下10^100次方好像也就几百个数字,直接就暴力A掉了。
老是觉得我用JAVA做题写得太繁了。
import java.util.Scanner;
import java.math.BigInteger;
class Main {
public static void main(String[] args) {
Scanner inScanner = new Scanner(System.in);
while (inScanner.hasNext()) {
BigInteger aBigInteger = new BigInteger("0");
BigInteger bBigInteger = new BigInteger("0");
aBigInteger = inScanner.nextBigInteger();
bBigInteger = inScanner.nextBigInteger();
if (aBigInteger.compareTo(new BigInteger("0")) == 0
&& bBigInteger.compareTo(new BigInteger("0")) == 0)
break;
else {
int count = 0;
BigInteger x = new BigInteger("0");
BigInteger y = new BigInteger("1");
BigInteger z = new BigInteger("1");
for (int i = 0;; i++) {
z = x.add(y);
if (z.compareTo(aBigInteger) >= 0
&& z.compareTo(bBigInteger) <= 0) {
count++;
}
x = y;
y = z;
if (z.compareTo(bBigInteger) > 0)
break;
}
System.out.println(count);
}
}
}
}