CF1710C.XOR Triangle

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

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

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

Here, \oplus denotes the bitwise XOR operation.

You should output the answer modulo 998244353998\,244\,353 .

Three positive values xx , yy , and zz are the sides of a non-degenerate triangle if and only if x+y>zx+y>z , x+z>yx+z>y , and y+z>xy+z>x .

输入格式

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

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

输出格式

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

输入输出样例

  • 输入#1

    101

    输出#1

    12
  • 输入#2

    1110

    输出#2

    780
  • 输入#3

    11011111101010010

    输出#3

    141427753

说明/提示

In the first test case, 1012=5101_2=5 .

  • The triple (a,b,c)=(0,3,5)(a, b, c) = (0, 3, 5) is valid because (ab,bc,ca)=(3,6,5)(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)(a, b, c) = (1, 2, 4) is valid because (ab,bc,ca)=(3,6,5)(a\oplus b, b\oplus c, c\oplus a) = (3, 6, 5) are the sides of a non-degenerate triangle.

The 66 permutations of each of these two triples are all the valid triples, thus the answer is 1212 .

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

首页