#CT00047. Số Fibonacci (Fibonacci Numbers)
Bài tập thuộc lộ trình
Mục lục đề ⌄
Số Fibonacci (Fibonacci Numbers)
Fibonacci Numbers
Version: Phuoc Hung OJ Extended
Problem Statement
The Fibonacci sequence is defined by , , and for . A positive integer is a Fibonacci number if for some index . Count each distinct value only once; in particular, is counted once even though .
Given positive integers with , count the Fibonacci values in the inclusive interval .
Input
One line contains the positive integers .
Output
Print one integer: the number of distinct Fibonacci values in .
Subtasks
- Subtask 1 (40 points): .
- Subtask 2 (30 points): .
- Subtask 3 (30 points): .
Examples
Example 1
Input
1 20
Output
6
Explanation
The distinct positive Fibonacci values up to are . The next value, , exceeds the upper endpoint. All six values are in the interval.
Example 2
Input
10 100
Output
5
Explanation
The values below are and do not count. The values in the requested range are , followed by , so there are five.
Example 3
Input
100 1000
Output
5
Explanation
The in-range Fibonacci values are . Their predecessor is below the interval and the successor is above it, giving five values.
Liên quan
Trong các cuộc thi sau: