dic = {0:0, 1:1}
def recursion(n):
if n in dic:
return dic[n]
if n < 1:
return 0
dic[n] = recursion(n-1) + recursion(n-2) + recursion(n-3)
return dic[n]
T = int(input())
arr = list()
for i in range(T):
arr.append(int(input()))
for i in arr:
print(recursion(i+1))
알고리즘