No.2279 OR Insertion
Problem Statement
You are given a string $S$ of length $N$ consisting only of 0 and 1.
Consider splitting $S$ into $1$ or more strings. Specifically, there are $N-1$ gaps between adjacent characters of $S$; choose $0$ or more of them, and split at all the chosen gaps. There are $\displaystyle 2^{N-1}$ ways to split. For each way of splitting, compute the value described below, and find the sum of these values modulo $998244353$.
- The bitwise OR of the resulting strings, each regarded as a base-$2$ integer
Input
$N$ $S$
- $1 \leq N \leq 4000$
- $S$ is a string of length $N$ consisting of
0and1 - $N$ is an integer
Output
Output the computed value, followed by a newline.
Sample
Sample 1
Input
3 110
Output
13
There are $4$ ways to split: $\{110\}, \{1,10\}, \{11,0\}, \{1,1,0\}$. Their respective bitwise ORs are as follows. (Shown in base-$10$ notation.)
$\{110\}→6, \{1,10\}→3, \{11,0\}→3, \{1,1,0\}→1$
Therefore, the sum is $13$.
Sample 2
Input
30 011100101010100001110100101010
Output
625160010
提出するには、Twitter 、GitHub、 Googleもしくは右上の雲マークをクリックしてアカウントを作成してください。
magsta
miscalc