10 100 1234567890 9876543210 0 0
5 4
import java.util.Scanner;
import java.math.BigInteger;
public class yhrtr {
public static void main(String[] args) {
Scanner cin = new Scanner (System.in);
BigInteger s[] = new BigInteger[1010];
s[1] = new BigInteger("1");
s[2] = new BigInteger("2");
for(int i=3;i<=1005;i++)
s[i] = s[i-1].add(s[i-2]);
BigInteger a,b,c;
while(cin.hasNext())
{
a = cin.nextBigInteger();
b = cin.nextBigInteger();
if(a.compareTo(BigInteger.ZERO)==0 && b.compareTo(BigInteger.ZERO)==0)
return ;
if(a.compareTo(b)>0)
{
c = a;
a = b;
b = c;
}
int sum = 0;
for(int i=1;i<=1005;i++)
{
if(s[i].compareTo(a)>=0 && s[i].compareTo(b)<=0)
sum++;
}
System.out.println(sum);
}
}
}HDUJ 1316 How Many Fibs?,布布扣,bubuko.com
原文地址:http://blog.csdn.net/hyccfy/article/details/38226503