http://acm.sdut.edu.cn/sdutoj/problem.php?action=showproblem&problemid=2321
题意:第一次用java写代码。。纪念一下。。虽然写的有点挫。。
1 import java.math.BigInteger; 2 import java.util.Scanner; 3 4 5 public class Main { 6 7 public static void main(String[] args) { 8 9 Scanner cin = new Scanner(System.in); 10 while(cin.hasNext()){ 11 int cnt = 0; 12 BigInteger l = cin.nextBigInteger(); 13 BigInteger r = cin.nextBigInteger(); 14 int t1 = l.compareTo(BigInteger.ZERO); 15 int t2 = r.compareTo(BigInteger.ZERO); 16 if (t1==0&&t2==0) 17 break; 18 BigInteger f1 = BigInteger.valueOf(1); 19 BigInteger f2 = BigInteger.valueOf(2); 20 int s1 = l.compareTo(f1); 21 int s2 = r.compareTo(f1); 22 if(s1<=0&&s2>=0) 23 cnt++; 24 s1 = l.compareTo(f2); 25 s2 = r.compareTo(f2); 26 if(s1<=0&&s2>=0) 27 cnt++; 28 while(true) 29 { 30 BigInteger f = f1.add(f2); 31 s1 = l.compareTo(f); 32 s2 = r.compareTo(f); 33 if(s1<=0&&s2>=0) 34 cnt++; 35 if (s2 < 0) 36 break; 37 f1 = f2; 38 f2 = f; 39 } 40 System.out.println(cnt); 41 42 } 43 } 44 45 }
原文:http://www.cnblogs.com/lahblogs/p/3644091.html