Codechef-JAM11.Mussadi lal and stairs

Problem NameMussadi lal and stairs
JudgeCodechef
Problem Linkhttps://www.codechef.com/problems/JAM11
Algorithms & DSDynamic Programming
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define PB push_back
#define VST(V) sort(V.begin(),V.end())
#define VSTrev(V) sort(V.begin(),V.end(),greater<long long int>())
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
ll mod=1e9+7;
ll dp[100100];
int main()
{
    dp[1]=dp[2]=dp[3]=1;
    for(ll i=1; i<=100000; i++)
    {
        for(ll j=1; j<4; j++)
        {
            ll tm=j+i;
            if(tm<=100000)
            {
                dp[tm]+=dp[i];
                dp[tm]%=mod;
            }
        }
    }
    //freopen("1input.txt","r",stdin);
    fast;
    ll tcase=1;
    cin>>tcase;
    for(ll test=1; test<=tcase; test++)
    {
        ll n;
        cin>>n;
        cout<<dp[n]<<"\n";
    }
    return 0;
}
Subscribe
Notify of
guest
0 Comments
Inline Feedbacks
View all comments
error: Alert: Content is protected !!