Counting Fibonacci Numbers
Time limit1sMemory limit256 MB
For each query pair a and b up to 10^100, count how many Fibonacci numbers fall in the closed interval [a, b].
- Level
Medium5 of 10
- Topics
- Math, Binary search, String, Brute force
- Solved
- No attempts yet
Problem
The Fibonacci numbers are defined as follows.
- (for )
Given two integers and , write a program that counts how many Fibonacci numbers lie in the interval . In other words, count the Fibonacci numbers that satisfy .
Input
The input consists of several test cases. Each test case is a single line containing two non-negative integers and separated by a space (). The two numbers are given without unnecessary leading zeros. The last line of the input contains two zeros, and this line is not processed.
Output
For each test case, print on its own line the number of Fibonacci numbers that satisfy .