125632024-12-23 12:26:12nkbalintJárda-L (40)cpp17Accepted 40/401ms540 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/01ms320 KiB
2Accepted0/01ms320 KiB
3Accepted2/21ms512 KiB
4Accepted2/21ms320 KiB
5Accepted2/21ms320 KiB
6Accepted2/21ms320 KiB
7Accepted2/21ms320 KiB
8Accepted3/31ms320 KiB
9Accepted3/31ms320 KiB
10Accepted3/31ms320 KiB
11Accepted3/31ms320 KiB
12Accepted3/31ms540 KiB
13Accepted3/31ms320 KiB
14Accepted3/31ms320 KiB
15Accepted3/31ms320 KiB
16Accepted3/31ms320 KiB
17Accepted3/31ms320 KiB