QOJ.ac

QOJ

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

#143. Exponential Formula

Estadísticas

Counting things and taking modulo $998244353$ or $10^9+7$ all the time, along with FFTs and multi-point evaluation, is something everyone is tired of.

For problems involving small prime moduli, there are many precedents, such as the problem of coefficients of high-order powers of small polynomials at distant positions that zx2003 tried to teach everyone last year.

Today, we won't do anything else, just modulo $2$. So, let's look at zeros and ones.

You are given a set of positive integers $S$. For each $1\le k\le n$, please determine how many ways there are to place balls labeled $1$ to $k$ into some boxes such that the number of balls in each box belongs to $S$. You only want to know the parity of the answer.

Note: The balls are distinct, and the boxes are identical.

Input

The input is a binary string of length $n$, where the $x$-th character is $1$ if $x\in S$.

Output

Output a binary string of length $n$, where the $k$-th character represents $a_k \bmod 2$.

Examples

Input 1

10110

Output 1

11000

Note 1

For Example 1, the number of ways for each $k$ is:

$k=1$: $\{\{1\}\}$, total $1$ way.

$k=2$: $\{\{1\},\{2\}\}$, total $1$ way.

$k=3$: $\{\{1\},\{2\},\{3\}\},\{\{1,2,3\}\}$, total $2$ ways.

$k=4$:

  • $\{\{1\},\{2\},\{3\},\{4\}\}$
  • $\{\{1,2,3\},\{4\}\}$
  • $\{\{1,2,4\},\{3\}\}$
  • $\{\{1,3,4\},\{2\}\}$
  • $\{\{1\}\{2,3,4\}\}$
  • $\{\{1,2,3,4\}\}$
  • Total $6$ ways.

$k=5$: Total $16$ ways, not listed individually.

Subtasks

For $10\%$ of the data, $n\le 10$.

For $40\%$ of the data, $n\le 2000$.

For $70\%$ of the data, $n\le 3\times 10^5$.

For $100\%$ of the data, $n\le 2\times 10^6$.

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.