40192023-03-09 08:53:09kdbJárdakövezés háromféle elemmelcpp17Accepted 30/304ms5080 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>f(n + 1), g(n + 1);
    f[0] = 1;
    f[1] = 2;
    g[1] = 2;

    for (int i = 2; i < n + 1; i++)
    {
        f[i] = (g[i - 1] * 2 + f[i - 1] * 2 + f[i - 2] * 3) % 2023;
        g[i] = (g[i - 1] + f[i - 1] * 2 + f[i - 2] * 2) % 2023;
    }
    cout << f[n] << endl;
    return 0;
}
SubtaskSumTestVerdictTimeMemory
base30/30
1Accepted0/03ms1832 KiB
2Accepted0/03ms2048 KiB
3Accepted2/23ms2264 KiB
4Accepted2/23ms2488 KiB
5Accepted2/22ms2560 KiB
6Accepted2/23ms2652 KiB
7Accepted2/22ms2732 KiB
8Accepted2/23ms2960 KiB
9Accepted2/23ms3444 KiB
10Accepted2/23ms3568 KiB
11Accepted2/24ms4492 KiB
12Accepted3/34ms4856 KiB
13Accepted3/33ms3716 KiB
14Accepted3/33ms4000 KiB
15Accepted3/34ms5080 KiB