http://162.105.81.212/JudgeOnline/problem?id=2413 高精度题目, 用Java水过. 有一个常识值得说下, Fib数列的第500项约为10^105 所以打标Fib的前500项即可. import java.io.BufferedInputStream; import java.math.BigInteger; import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner in = new Scanner(new BufferedInputStream(System.in)); BigInteger big[] = new BigInteger[501]; big[1] = BigInteger.valueOf(1); big[2] = BigInteger.valueOf(2); for(int i=3; i<=500; i++) big[i] = big[i-1].add(big[i-2]); int i, ret; BigInteger a, b; while(true) { a = in.nextBigInteger(); b = in.nextBigInteger(); if(a.compareTo(b) == 0 && a.compareTo(BigInteger.valueOf(0)) == 0) break; i = 1; ret = 0; while(big[i].compareTo(a) < 0) i++; while(big[i].compareTo(b) <= 0) { ret++; i++; } System.out.println(ret); } } }