#include <stdio.h>
int dp[11];
int top_down(int n) {
if (n==1) return 1;
if (n==2) return 2;
if (n==3) return 4;
if(dp[n]!=0) return dp[n];
dp[n]= top_down(n-1)+top_down(n-2)+top_down(n-3);
return dp[n];
}
int main() {
int t;
scanf("%d",&t);
while(t--) {
int n;
scanf("%d",&n);
printf("%d\n",top_down(n));
}
return 0;
}
To embed this project on your website, copy the following code and paste it into your website's HTML: