87642024-01-29 15:15:50Balki22Toronyépítés (80 pont)cpp17Runtime error 78/8018ms18636 KiB
#include <bits/stdc++.h>
using namespace std;

int main() {
	unsigned long long n; cin >> n;
	if (n == 0) {
		cout << 1;
		return 0;
	}
	vector<unsigned long long> dp(n, 0);
	dp[0] = 1;
	dp[1] = 3;
	for (unsigned long long i = 2; i <= n; i++) {
		dp[i] = ((3 * dp[i-1]) % 20210108 + dp[i-2]) % 20210108;
	}
	cout << dp[n];
}
SubtaskSumTestVerdictTimeMemory
base78/80
1Runtime error0/03ms1788 KiB
2Runtime error0/03ms2052 KiB
3Accepted4/43ms2220 KiB
4Accepted4/43ms2260 KiB
5Accepted5/53ms2468 KiB
6Accepted5/53ms2600 KiB
7Accepted6/618ms18336 KiB
8Accepted6/64ms4872 KiB
9Accepted7/73ms3324 KiB
10Accepted7/72ms3292 KiB
11Accepted8/86ms6460 KiB
12Accepted8/818ms18636 KiB
13Accepted8/817ms17348 KiB
14Accepted8/88ms8808 KiB
15Runtime error0/23ms4008 KiB
16Accepted2/23ms4104 KiB