15352022-11-22 12:58:11TomaSajtJárda-L (40)cpp14Accepted 40/403ms3424 KiB
#include <bits/stdc++.h>
#define speed ios::sync_with_stdio(0);cin.tie(0)
using namespace std;

int main() {
    speed;
    int n;
    cin >> n;
    vector<int> a(n + 1), b(n + 1);
    a[0] = 1;
    b[0] = 0;
    a[1] = 1;
    b[1] = 2;
    for (int i = 2; i <= n; i++) {
        a[i] = a[i - 2] + a[i - 1] + b[i - 2];
        b[i] = b[i - 1] + 2 * a[i - 1];
    }
    cout << a[n];
}
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1824 KiB
2Accepted0/02ms2016 KiB
3Accepted2/22ms2244 KiB
4Accepted2/22ms2300 KiB
5Accepted2/22ms2372 KiB
6Accepted2/22ms2604 KiB
7Accepted2/22ms2576 KiB
8Accepted3/32ms2704 KiB
9Accepted3/32ms2908 KiB
10Accepted3/32ms2980 KiB
11Accepted3/32ms2980 KiB
12Accepted3/32ms2984 KiB
13Accepted3/32ms3108 KiB
14Accepted3/32ms3188 KiB
15Accepted3/32ms3296 KiB
16Accepted3/32ms3292 KiB
17Accepted3/32ms3424 KiB