- 다이나믹 프로그래밍을 이용한 피보나치 수의 개수를 구하는 문제였다.
- 주의해야 할 점이 있다면
dp[1] = 1
,dp[2] = 2
라는 점이다.
import sys
input = sys.stdin.readline
dp = [0] * 1001
dp[1] = 1
dp[2] = 2
for i in range(3, 1001):
dp[i] = dp[i-1] + dp[i-2]
while True:
cnt = 0
a, b = map(int, input().strip().split())
if a == 0 and b == 0:
break
else:
for i in range(1, 1001):
if dp[i] >= a and dp[i] <= b:
cnt += 1
print(cnt)