QOJ.ac

QOJ

Time Limit: 1 s Memory Limit: 1024 MB Total points: 100

#3763. Absolute Difference Equation

統計

For a sequence $a_1, a_2, \ldots, a_n$, consider the following operation $f$: $f(a)=\{b_1, b_2, \ldots, b_{n-1}\}$, where $b_i=|a_i-a_{i+1}|$.

After applying the operation $f$ for $n-1$ times, denoted by $f^{n-1}(a)$, the sequence will become a single element.

Bobo has a sequence $a$ of length $n$ filled with 0, 1 and ?. He would like to know the number of ways modulo $(10^9+7)$ to replace ? to 0 or 1 such that $f^{n-1}(a)=\{1\}$.

Input

The input consists of several test cases terminated by end-of-file. For each test case:

The first line contains a nonempty string $a$ consisting only of 0, 1 and ?, denoting the given sequence.

  • $1 \leq |a| \leq 10^6$
  • The sum of $|a|$ does not exceed $10^7$.

Output

For each test case, print an integer which denotes the result.

Sample Input

1
?????
1010?1?0

Sample Output

1
16
2

Discussions

About Discussions

The discussion section is only for posting: Editorials, 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. Submitting multiple issues may cause your account to be banned.
  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.