128772025-01-02 19:49:26BucsMateJárda-L (40)cpp17Accepted 40/402ms548 KiB
#include <iostream>

using namespace std;

int main()
{
    int N;
    cin >> N;

    int a[29] = {}, b[29] = {};

    a[1] = 1;
    a[2] = 2;
    b[1] = 0;
    b[2] = 1;

    for(int i = 3; i <= N; i++)
    {
        a[i] = a[i-1] + a[i-2] + 2*b[i-1];
        b[i] = a[i-2] + b[i-1];
    }

    cout << a[N];

    return 0;
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/01ms320 KiB
2Accepted0/01ms320 KiB
3Accepted2/21ms320 KiB
4Accepted2/21ms320 KiB
5Accepted2/21ms320 KiB
6Accepted2/21ms320 KiB
7Accepted2/21ms360 KiB
8Accepted3/31ms320 KiB
9Accepted3/32ms320 KiB
10Accepted3/31ms508 KiB
11Accepted3/32ms320 KiB
12Accepted3/31ms548 KiB
13Accepted3/31ms344 KiB
14Accepted3/31ms320 KiB
15Accepted3/31ms320 KiB
16Accepted3/31ms320 KiB
17Accepted3/31ms320 KiB