No.2058 Binary String
タグ : / 解いたユーザー数 98
作問者 :
taiga0629kyopro
/ テスター :
nok0
Problem Statement
You are given positive integers $N,K$. A sequence of length $N$ is called a good sequence if it satisfies the following conditions.
- For every integer $i$ satisfying $1 \le i \le N $, $ S_i \in \lbrace 0,1 \rbrace$
- $\displaystyle \sum_{i=1}^N S_i \equiv 0 \ (\mathrm{mod}\ 2)$
For a good sequence $S$, let $f(S)$ be the minimum number of operations required to make all elements of $S$ equal to $0$ by performing the following operation $0$ or more times. (If $S$ is a good sequence, $f(S)$ is a finite value.)
- Choose one integer $i$ satisfying $1 \le i \le N-1$, replace $S_i$ with $1-S_i$, and replace $S_{i+1}$ with $1-S_{i+1}$.
There are $2^{N-1}$ good sequences $S$. Compute $f(S)$$^K$ for all of them, and find the sum of these values modulo $998244353$.
Input
$N$ $K$
Output
Print the sum of $f(S)^K$ modulo $998244353$.
Sample
Sample 1
Input
3 2
Output
6
We have $f((0,0,0))=0、f((1,1,0))=f((0,1,1))=1、f((1,0,1))=2$. Therefore, the answer is $1^2+1^2+2^2=6$.
Sample 2
Input
10 3
Output
62208
Sample 3
Input
200000 2
Output
829773566
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。