51322023-04-19 19:29:11anonJárdakövezés háromféle elemmelcpp17Accepted 30/304ms5064 KiB
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a{1, 2}, b{1, 1};
    a.resize(n + 1);
    b.resize(n + 1);
    for (int i = 2; i <= n; ++i) {
        a[i] = (2 * a[i - 1] + 3 * a[i - 2] + 4 * b[i - 1]) % 2023;
        b[i] = (a[i - 1] + a[i - 2] + b[i - 1]) % 2023;
    }
    cout << a[n] << endl;
}
SubtaskSumTestVerdictTimeMemory
base30/30
1Accepted0/03ms1976 KiB
2Accepted0/03ms2116 KiB
3Accepted2/23ms2248 KiB
4Accepted2/23ms2632 KiB
5Accepted2/23ms2704 KiB
6Accepted2/23ms2772 KiB
7Accepted2/23ms3004 KiB
8Accepted2/22ms2980 KiB
9Accepted2/23ms3236 KiB
10Accepted2/23ms3364 KiB
11Accepted2/24ms3796 KiB
12Accepted3/34ms4384 KiB
13Accepted3/33ms3620 KiB
14Accepted3/33ms3852 KiB
15Accepted3/34ms5064 KiB