CF BUDDY
← Problems·

1051D · Bicolorings

1700 · bitmasks, dp

Problem: You are given a grid, consisting of 22 rows and nn columns. Each cell of this grid should be colored either black or white.

Two cells are considered neighbours if they have a common border and share the same color. Two cells AA and BB belong to the same component if they are neighbours, or if there is a neighbour of AA that belongs to the same component with BB.

Let's call some bicoloring beautiful if it has exactly kk components.

Count the number of beautiful bicolorings. The number can be big enough, so print the answer modulo 998244353998244353.

Input Format: The only line contains two integers nn and kk (1n10001 \le n \le 1000, 1k2n1 \le k \le 2n) — the number of columns in a grid and the number of components required.

Output Format: Print a single integer — the number of beautiful bicolorings modulo 998244353998244353.

Note: One of possible bicolorings in sample 11:

Sample Cases

Case 1

Input

3 4

Output

12

Case 2

Input

4 1

Output

2

Case 3

Input

1 2

Output

2

Similar problems

00:00:00
Loading editor…
Welcome! I'm your coding tutor for this problem. Use the chips below to reveal stored hints or get AI feedback on your code. I'll guide you step by step — never giving away the solution.

Sign in to unlock AI tutor feedback