`
lilisalo
  • 浏览: 1111278 次
文章分类
社区版块
存档分类
最新评论

UVA 10183 斐波那契数列

 
阅读更多

Problem B: How many Fibs?

Recall the definition of the Fibonacci numbers:

f1:= 1
f2:= 2
fn:=fn-1+fn-2 (n>=3)

Given two numbersaandb, calculate how many Fibonacci numbers are in the range [a,b].

Input Specification

The input contains several test cases. Each test case consists of two non-negative integer numbersaandb. Input is terminated bya=b=0. Otherwise,a<=b<=10100. The numbersaandbare given with no superfluous leading zeros.

Output Specification

For each test case output on a single line the number of Fibonacci numbersfiwitha<=fi<=b.

Sample Input

10 100
1234567890 9876543210
0 0

Sample Output

5
4

直接利用java大数可以水过


分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics