QOJ.ac

QOJ

Límite de tiempo: 1 s Límite de memoria: 512 MB Puntuación total: 100

#2892. Valid Sequence

Estadísticas

For a 0-1 sequence $s$ of length $n$, we index its bits from left to right starting from zero, denoted as $s_0, s_1, \dots, s_{n-1}$.

Given a positive integer $k$, consider any subsegment of length $k$ from $s$. Interpreting this subsegment as a $k$-bit binary number with the left side as the most significant bit and the right side as the least significant bit, we denote its value as $t$, where $0 \le t < 2^k$.

There are $n - k + 1$ such subsegments of length $k$ in $s$. A sequence $s$ is called "legal" if for every such subsegment, when interpreted as a binary number $t$, the bit at index $t$ in $s$ (i.e., $s_t$) is $1$. It is guaranteed that $2^k \le n$, so $t$ will never be an out-of-bounds index for $s$.

Given $n$ and $k$, find the number of legal sequences $s$. Since the number of such sequences may be large, output the result modulo $998,244,353$.

Input

The input consists of a single line containing two space-separated positive integers $n$ and $k$.

It is guaranteed that $1 \le k \le 4$ and $2^k \le n \le 500$.

Output

Output a single line containing a non-negative integer representing the number of legal sequences modulo $998,244,353$.

Examples

Input 1

4 2

Output 1

2

Note 1

The two sequences that satisfy the requirements are $0, 1, 1, 1$ and $1, 1, 1, 1$.

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.