C/C++식 코드
import sys
input = sys.stdin.readline
def finder(n):
dp = [[0,0,0] for i in range(n)]
for i in range(0,n):
if(i == 0):
dp[0] = [1,0,0]
elif(i == 1):
dp[1] = [1,1,0]
elif(i == 2):
dp[2] = [1,1,1]
else:
dp[i][0] = dp[i-1][0]
dp[i][1] = dp[i-2][1] + dp[i-2][0]
dp[i][2] = dp[i-3][2] + dp[i-3][1] + dp[i-3][0]
return sum(dp[n-1][:3])
for i in range(int(input())):
a = int(input())
print(finder(a))
Pythonic 코드
import sys
input = sys.stdin.readline
t = int(input())
dp = [1 for i in range(10001)]
lst = []
for i in range(t):
lst.append(int(input()))
for i in range(2, 10001):
dp[i] += dp[i - 2]
for i in range(3, 10001):
dp[i] += dp[i - 3]
for i in lst:
print(dp[i])