Codeforces Round 810 (Div. 2)
E
XOR Triangle
Codeforces
未评级
原题
← D→
翻译中…

You are given a positive integer $n$. Since $n$ may be very large, you are given its binary representation.

翻译中…

You should compute the number of triples $(a,b,c)$ with $0 \leq a,b,c \leq n$ such that $a \oplus b$, $b \oplus c$, and $a \oplus c$ are the sides of a non-degenerate triangle.

翻译中…

Here, $\oplus$ denotes the bitwise XOR operation.

翻译中…

You should output the answer modulo $998\,244\,353$.

翻译中…

Three positive values $x$, $y$, and $z$ are the sides of a non-degenerate triangle if and only if $x+y \gt z$, $x+z \gt y$, and $y+z \gt x$.

翻译中…

Input

翻译中…

The first and only line contains the binary representation of an integer $n$ ($0 \lt n \lt 2^{200\,000}$) without leading zeros.

翻译中…

For example, the string 10 is the binary representation of the number $2$, while the string 1010 represents the number $10$.

翻译中…

Output

翻译中…

Print one integer — the number of triples $(a,b,c)$ satisfying the conditions described in the statement modulo $998\,244\,353$.

翻译中…

Note

翻译中…

In the first test case, $101_2=5$.

翻译中…
  • The triple $(a, b, c) = (0, 3, 5)$ is valid because $(a\oplus b, b\oplus c, c\oplus a) = (3, 6, 5)$ are the sides of a non-degenerate triangle.
  • The triple $(a, b, c) = (1, 2, 4)$ is valid because $(a\oplus b, b\oplus c, c\oplus a) = (3, 6, 5)$ are the sides of a non-degenerate triangle.
翻译中…

The $6$ permutations of each of these two triples are all the valid triples, thus the answer is $12$.

翻译中…

In the third test case, $11\,011\,111\,101\,010\,010_2=114\,514$. The full answer (before taking the modulo) is $1\,466\,408\,118\,808\,164$.

翻译中…

样例

Input #1
101
Output #1
12
InputCopy OutputCopy
Input #2
1110
Output #2
780
InputCopy OutputCopy
Input #3
11011111101010010
Output #3
141427753
InputCopy OutputCopy
题目信息
题号
1711E
时间限制
4 s
内存限制
512 MB

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。