[알고리즘/백준] 9095번 : 1, 2, 3 더하기(python)

유현민·2022년 3월 14일
0

알고리즘

목록 보기
51/253

1부터 4까지 계산해보니 점화식을 세울 수 있었다.

for _ in range(int(input())):
    n = int(input())
    a = [0, 1, 2, 4] + [0] * n
    for i in range(4, n + 1):
        a[i] = a[i-1] + a[i-2] + a[i-3]
    print(a[n])
profile
smilegate megaport infra

0개의 댓글