No.2839 AND Constraint
タグ : / 解いたユーザー数 41
作問者 :
milkcoffee
/ テスター :
とりゐ
Problem Statement
You have a variable $x=0$. For each $i = 1,2,\dots,2^N-1$ in order, perform the following operation.
- Let $k$ be "the number of consecutive $0$s at the end of the binary representation of $i$". $($For example, when $i=6$, the binary representation of $6$ is $110$, so $k=1$.$)$
Choose an integer $y$ satisfying $0 \leq y \leq 2^k$ and $(x+y) \ \text{AND} \ i = (x+y)$, and replace $x$ with $x+y$.
Here, $\text{AND}$ denotes the bitwise logical AND. See Sample $1$ for concrete examples of the operations.
Among the $2^N-1$ operations, $M$ operations are performed with $y \geq 1$, and the remaining $2^N-1-M$ operations are performed with $y=0$.
Find the number of possible sequences of $2^N-1$ operations, modulo $998244353$.
Here, $2$ sequences of operations are considered the same if "the chosen integer $y$ is equal for every operation".
Input
$N$ $M$
- $1 \leq N,M \leq 500$
- All input values are integers
Output
Output the answer as an integer.
Sample
Sample 1
Input
2 2
Output
2
$2^N-1 = 3$ operations are performed, and we count the sequences in which the number of operations performed with $y \geq 1$ is $2$.
For the $2$ possible sequences of operations, the value of $x$ before and after each operation is shown below. $($The integer above each arrow is the value of $y$ chosen in that operation.$)$
For example, the following sequences of operations are impossible.
Sample 2
Input
3 7
Output
1
Only the following $1$ sequence satisfies the conditions. $($The notation is the same as in Sample $1$.$)$
Sample 3
Input
1 500
Output
0
Since the operation is performed only $1$ time, an operation with $y \geq 1$ can be performed at most $1$ time. Therefore, clearly no sequence of operations satisfies the conditions.
Sample 4
Input
234 432
Output
611707541
Find the answer modulo $998244353$.
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。