#include <stdio.h>
long long dp[101];
long long top_down(int n) {
    if(n==1) return 1;
    else if(n==2) return 1;
    else if(n==3) return 1;
    else if(n==4) return 2;
    else if(n==5) return 2;

    if(dp[n]!=0) return dp[n];

    return dp[n]=top_down(n-1)+top_down(n-5);
}


int main() {
    int t;
    scanf("%d",&t);
    while(t--) {
        int n;
        scanf("%d",&n);
        printf("%lld\n",top_down(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: