Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <bits/stdc++.h>
- using namespace std;
- typedef long long LL;
- const LL MOD = 998244353;
- const int maxn = 10;
- int n, m;
- LL ans;
- LL dp[2][maxn][maxn][maxn][maxn];
- int main() {
- #ifdef ExRoc
- freopen("test.txt", "r", stdin);
- #endif // ExRoc
- ios::sync_with_stdio(false);
- cin >> n >> m;
- for (int a = 1; a < 10; a += 2) {
- for (int b = 0; b < 10; b += 2) {
- for (int c = 1; c < 10; c += 2) {
- for (int d = 0; d < 10; d += 2) {
- if (a + b + c + d <= m) {
- dp[0][a][b][c][d] = 1;
- }
- }
- }
- }
- }
- for (int i = 5; i <= n; ++i) {
- int nowi = (i % 2);
- int prei = nowi ^ 1;
- memset(dp[nowi], 0, sizeof(dp[nowi]));
- for (int e = nowi; e < 10; e += 2) {
- for (int d = nowi ^ 1; d < 10; d += 2) {
- for (int c = nowi; c < 10; c += 2) {
- for (int b = nowi ^ 1; b < 10; b += 2) {
- for (int a = nowi; a < 10; a += 2) {
- if (a + b + c + d + e > m) {
- continue;
- }
- dp[nowi][b][c][d][e] =
- (dp[nowi][b][c][d][e] + dp[prei][a][b][c][d]) %
- MOD;
- }
- }
- }
- }
- }
- }
- for (int a = 0; a < 10; ++a) {
- for (int b = 0; b < 10; ++b) {
- for (int c = 0; c < 10; ++c) {
- for (int d = 0; d < 10; ++d) {
- ans = (ans + dp[n & 1][a][b][c][d]) % MOD;
- }
- }
- }
- }
- cout << ans << endl;
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement