[白俊]9095


質問する


https://www.acmicpc.net/problem/9095


に答える

# bottom-up
import sys

t = int(sys.stdin.readline().rstrip())

for i in range(t):
    n = int(sys.stdin.readline().rstrip())
    d = [0] * 11
    d[0] = 1
    d[1] = 1
    d[2] = 2
    for j in range(3, n+1):
        d[j] = d[j-1] + d[j-2] + d[j-3]
    print(d[n])