标签:equals imp image rgs 函数 logs blog val sys
问题描述:
源码:
import java.math.BigInteger; import java.util.*; public class Main { //主函数 public static void main(String[] args) { BigInteger a, b, zero = BigInteger.valueOf(0), f1, f2, fn; int count; Scanner cin = new Scanner(System.in); while(true) { a = cin.nextBigInteger(); b = cin.nextBigInteger(); if(a.equals(zero) && b.equals(zero))break; count = 0; f1 = BigInteger.valueOf(1); if(a.compareTo(f1) <= 0 && b.compareTo(f1) >= 0)count++; f2 = BigInteger.valueOf(2); if(a.compareTo(f2) <= 0 && b.compareTo(f2) >= 0)count++; while(true) { fn = f2.add(f1); if(a.compareTo(fn) <= 0 && b.compareTo(fn) >= 0)count++; else if(b.compareTo(fn) < 0)break; f1 = f2; f2 = fn; } System.out.println(count); } } }
HD-ACM算法专攻系列(13)——How Many Fibs?
标签:equals imp image rgs 函数 logs blog val sys
原文地址:http://www.cnblogs.com/forcheng/p/7634883.html