CF1710C.XOR Triangle

省选/NOI-

通过率:0%

时间限制:4.00s

内存限制:512MB

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 0≤a,b,c≤n0 \leq a,b,c \leq n such that a⊕ba \oplus b, b⊕cb \oplus c, and a⊕ca \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 353998\,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 \gt z, x+z>yx+z \gt y, and y+z>xy+z \gt x.

给你一个正整数 nn。由于 nn 可能非常大,你将获得其二进制表示。

你需要计算满足 0≤a,b,c≤n0 \leq a,b,c \leq n 的三元组 (a,b,c)(a,b,c) 的个数,使得 a⊕ba \oplus b、b⊕cb \oplus c 和 a⊕ca \oplus c 构成一个非退化三角形的三条边。

此处,⊕\oplus 表示按位异或运算。

请将答案对 998 244 353998\,244\,353 取模后输出。

三个正数 xx、yy、zz 构成一个非退化三角形的充要条件是:
x+y>zx+y > z,x+z>yx+z > y,且 y+z>xy+z > x。

输入格式

The first and only line contains the binary representation of an integer nn (0<n<2200 0000 \lt n \lt 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.

第一行且仅有一行包含一个整数 nn 的二进制表示(0<n<2200 0000 \lt n \lt 2^{200\,000}),不含前导零。

例如,字符串 10 是数字 22 的二进制表示,而字符串 1010 表示数字 1010。

输出格式

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

输出一个整数——满足题目描述中条件的三元组 (a,b,c)(a,b,c) 的个数,对 998 244 353998\,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 (a⊕b,b⊕c,c⊕a)=(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 (a⊕b,b⊕c,c⊕a)=(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, 11 011 111 101 010 0102=114 51411\,011\,111\,101\,010\,010_2=114\,514. The full answer (before taking the modulo) is 1 466 408 118 808 1641\,466\,408\,118\,808\,164.

在第一个测试用例中,1012=5101_2=5。

  • 三元组 (a,b,c)=(0,3,5)(a, b, c) = (0, 3, 5) 是合法的,因为 (a⊕b,b⊕c,c⊕a)=(3,6,5)(a\oplus b, b\oplus c, c\oplus a) = (3, 6, 5) 可构成一个非退化三角形的三条边。
  • 三元组 (a,b,c)=(1,2,4)(a, b, c) = (1, 2, 4) 是合法的,因为 (a⊕b,b⊕c,c⊕a)=(3,6,5)(a\oplus b, b\oplus c, c\oplus a) = (3, 6, 5) 可构成一个非退化三角形的三条边。

上述两个三元组各自的 66 种排列构成了全部合法三元组,因此答案为 1212。

在第三个测试用例中,11 011 111 101 010 0102=114 51411\,011\,111\,101\,010\,010_2=114\,514。完整答案(取模前)为 1 466 408 118 808 1641\,466\,408\,118\,808\,164。

输入解题思路,AI测评打分。不知道怎么写?

首页