코드
import java.io.*;
public class Main{
static Integer[] dp;
public static void main(String[] args) throws IOException{
BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
int N = Integer.parseInt(br.readLine());
dp = new Integer[11];
dp[1] = 1;
dp[2] = 2;
dp[3] = 4;
for (int i = 0; i < N; i++) {
int T = Integer.parseInt(br.readLine());
System.out.println(solution(T));
}
}
static int solution(int n) {
if (n == 0) {
return 0;
}
if (dp[n] == null) {
dp[n] = solution(n - 1) + solution(n - 2) + solution(n - 3);
}
return dp[n];
}
}