227182026-01-15 17:10:02algoproJárdakövezés háromféle elemmelcpp17Accepted 30/303ms1092 KiB
// UUID: 67260a5c-274b-4e6a-8faf-17a1f5889794
#include <bits/stdc++.h>
using namespace std;

int main() {
	int n; cin>>n;
	if(n==1){
		cout<<2; return 0;
	}
	vector<int>dpa(n+1);
	vector<int>dpb(n+1);
	dpa[0]=0;
	dpb[0]=1;
	dpa[1]=1;
	dpb[1]=2;
	for(int i=2; i<n+1; i++){
		dpa[i]=(dpb[i-1]+dpa[i-1]+dpb[i-2])%2023;
		dpb[i]=(3*dpa[i-1]+2*dpb[i-2]+dpb[i-1]+dpa[i])%2023;
	}
	cout<<dpb[n];
}
SubtaskSumTestVerdictTimeMemory
base30/30
1Accepted0/01ms512 KiB
2Accepted0/01ms316 KiB
3Accepted2/21ms316 KiB
4Accepted2/21ms500 KiB
5Accepted2/21ms316 KiB
6Accepted2/21ms316 KiB
7Accepted2/21ms316 KiB
8Accepted2/21ms508 KiB
9Accepted2/22ms564 KiB
10Accepted2/22ms884 KiB
11Accepted2/22ms932 KiB
12Accepted3/33ms820 KiB
13Accepted3/31ms316 KiB
14Accepted3/31ms316 KiB
15Accepted3/33ms1092 KiB