17682022-12-02 21:03:49kdbJárda-L (40)cpp11Accepted 40/403ms3824 KiB
#include <iostream>
#include <vector>
using namespace std;
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    int n; cin >> n;
    vector<int> a(n+1), b(n+1);
    a[0] = 1; a[1] = 1; b[1] = 1;
    for (size_t i = 2; i < n + 1; i++)
    {
        a[i] = a[i - 1] + a[i - 2] + 2 * b[i - 2];
        b[i] = a[i - 1] + b[i - 1];
    }
    cout << a[n] << endl;
    return 0;
}
/*
3
-5

24
-80897393
*/
SubtaskSumTestVerdictTimeMemory
base40/40
1Accepted0/03ms1696 KiB
2Accepted0/02ms2200 KiB
3Accepted2/22ms2156 KiB
4Accepted2/22ms2312 KiB
5Accepted2/22ms2500 KiB
6Accepted2/22ms2720 KiB
7Accepted2/22ms2928 KiB
8Accepted3/32ms3096 KiB
9Accepted3/32ms3296 KiB
10Accepted3/32ms3376 KiB
11Accepted3/32ms3476 KiB
12Accepted3/32ms3668 KiB
13Accepted3/32ms3824 KiB
14Accepted3/32ms3676 KiB
15Accepted3/32ms3820 KiB
16Accepted3/32ms3668 KiB
17Accepted3/32ms3820 KiB