#include <stdio.h>

int bottom_up(int n) {
    int dp[11];
    dp[1]=1;
    dp[2]=2;
    dp[3]=4;

    for(int i=4; i<=n; i++) {
        dp[i]=dp[i-1]+dp[i-2]+dp[i-3];
    }
    return dp[n];
}

int main() {
    int t,n;
    scanf("%d",&t);
    while(t--) {
        scanf("%d",&n);
        printf("%d\n",bottom_up(n));
    }
    return 0;
}

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: