728x90
반응형
기본적인 다이나믹 프로그래밍 문제이다.
n = int(input())
if n < 2:
print(1)
else:
a, b = 1, 1
for i in range(n-1):
a, b = a+b+1, a
print(a%1000000007)
728x90
반응형
'Agorithm > 백준 알고리즘' 카테고리의 다른 글
백준 알고리즘 1016번 제곱 ㄴㄴ 수(python) (0) | 2021.03.20 |
---|---|
백준 알고리즘 11660번 구간 합 구하기 5(python) (0) | 2021.03.20 |
백준 알고리즘 15624번 피보나치 수 7(python) (0) | 2021.03.19 |
백준 알고리즘 14495번 피보나치 비스무리한 수열(python) (0) | 2021.03.19 |
백준 알고리즘 9507번 Generations of Tribbles(python) (0) | 2021.03.19 |