파도반 수열 (9641) 본문
728x90
t = int(input())
def tri_cnt(n):
cnt = [1,1,1]
if n == 0 or n == 1 or n == 2:
return 1
else:
for i in range(3, n+1):
cnt.append(cnt[i-3] + cnt[i-2])
return cnt[n]
for _ in range(t):
n = int(input())
print(tri_cnt(n-1))
'Algorithms > DP (Dynamic Programming)' 카테고리의 다른 글
전깃줄 (2565) (0) | 2020.05.19 |
---|---|
연속합 (1912) (0) | 2020.05.19 |
RGB 거리 (1149) (0) | 2020.05.19 |
피보나치 함수 (1003) (0) | 2020.05.19 |
피보나치 수2 (2748) (0) | 2020.05.19 |
Comments