https://cn.vjudge.net/problem/UVA-10183
题目没难度,C++写法需要高精度,这里练习使用Java的BigInteger类,毕竟刚学……
Java的语法真是冗长……
import java.util.*;
import java.math.*;
public class Main
{
public static void main(String args[])
{
Scanner cin = new Scanner(System.in);
BigInteger a, b;
while (cin.hasNext())
{
a = cin.nextBigInteger(); b = cin.nextBigInteger();
if (a.equals(BigInteger.ZERO) && b.equals(BigInteger.ZERO))
break;
BigInteger f0 = BigInteger.ONE, f1 = BigInteger.ONE;
BigInteger ans = BigInteger.ZERO;
while (f1.compareTo(b) <= 0)
{
if (f1.compareTo(a) >= 0) ans = ans.add(BigInteger.ONE);
BigInteger tmp = f1;
f1 = f1.add(f0);
f0 = tmp;
}
System.out.println(ans);
}
}
}