15202022-11-21 21:33:57kicsiboglarJárda-L (40)cpp11Accepted 40/403ms3412 KiB
#include <iostream>
#include <vector>

#define ll long long
#define ull unsigned long long
using namespace std;

//ifstream cin ("input.in");
//ofstream cout ("output.out");

ll n,m,i,j,a,b,k;

int main()
{

    cin>>n;
    if (n==1) 
    {
        cout<<"1";
        return 0;
    }
    if (n==2) 
    {
        cout<<"2";
        return 0;
    }
    if (n==3) 
    {
        cout<<"5";
        return 0;
    }
    vector <ull> dp(n+1);
    dp[0]=1;
    dp[1]=1;
    dp[2]=2;
    dp[3]=5;
    for (i=4;i<=n;++i)
    {
        dp[i]=dp[i-1]+dp[i-2];
        j=i-3;
        while (j>=0) 
        {
            dp[i]+=dp[j]*2;
            j--;
        }
    }
    cout<<dp[n];
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1808 KiB
2Accepted0/02ms2344 KiB
3Accepted2/22ms2400 KiB
4Accepted2/22ms2752 KiB
5Accepted2/22ms2756 KiB
6Accepted2/22ms2800 KiB
7Accepted2/22ms2800 KiB
8Accepted3/32ms2916 KiB
9Accepted3/32ms2812 KiB
10Accepted3/32ms3000 KiB
11Accepted3/32ms3080 KiB
12Accepted3/32ms3080 KiB
13Accepted3/32ms3208 KiB
14Accepted3/32ms3288 KiB
15Accepted3/32ms3284 KiB
16Accepted3/32ms3284 KiB
17Accepted3/32ms3412 KiB