125612024-12-23 12:23:37vauvau6Járda-L (40)cpp17Accepted 40/401ms508 KiB
#include <iostream>
#include <vector>

using namespace std;

int i,v[29],n;
int main()
{
    cin>>n;
    v[1]=1;
    v[2]=2;
    v[3]=5;
    v[4]=11;
    if(n>4)
    {
        for(i=5;i<=n;++i)
        {
            v[i]=v[i-1]*2+v[i-3];
        }
    }
    cout<<v[n];
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/01ms508 KiB
2Accepted0/01ms320 KiB
3Accepted2/21ms320 KiB
4Accepted2/21ms320 KiB
5Accepted2/21ms320 KiB
6Accepted2/21ms320 KiB
7Accepted2/21ms320 KiB
8Accepted3/31ms388 KiB
9Accepted3/31ms320 KiB
10Accepted3/31ms320 KiB
11Accepted3/31ms320 KiB
12Accepted3/31ms332 KiB
13Accepted3/31ms320 KiB
14Accepted3/31ms320 KiB
15Accepted3/31ms320 KiB
16Accepted3/31ms508 KiB
17Accepted3/31ms320 KiB