CF1710C.XOR Triangle
省选/NOI-
通过率:0%
时间限制:4.00s
内存限制:512MB
AC君温馨提醒
该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
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≤a,b,c≤n such that a⊕b, b⊕c, and a⊕c are the sides of a non-degenerate triangle.
Here, ⊕ denotes the bitwise XOR operation.
You should output the answer modulo 998244353.
Three positive values x, y, and z are the sides of a non-degenerate triangle if and only if x+y>z, x+z>y, and y+z>x.
给你一个正整数 n。由于 n 可能非常大,你将获得其二进制表示。
你需要计算满足 0≤a,b,c≤n 的三元组 (a,b,c) 的个数,使得 a⊕b、b⊕c 和 a⊕c 构成一个非退化三角形的三条边。
此处,⊕ 表示按位异或运算。
请将答案对 998244353 取模后输出。
三个正数 x、y、z 构成一个非退化三角形的充要条件是:
x+y>z,x+z>y,且 y+z>x。
输入格式
The first and only line contains the binary representation of an integer n (0<n<2200000) without leading zeros.
For example, the string 10 is the binary representation of the number 2, while the string 1010 represents the number 10.
第一行且仅有一行包含一个整数 n 的二进制表示(0<n<2200000),不含前导零。
例如,字符串 10 是数字 2 的二进制表示,而字符串 1010 表示数字 10。
输出格式
Print one integer — the number of triples (a,b,c) satisfying the conditions described in the statement modulo 998244353.
输出一个整数——满足题目描述中条件的三元组 (a,b,c) 的个数,对 998244353 取模。
输入输出样例
输入#1
101
输出#1
12
输入#2
1110
输出#2
780
输入#3
11011111101010010
输出#3
141427753
说明/提示
In the first test case, 1012=5.
- The triple (a,b,c)=(0,3,5) is valid because (a⊕b,b⊕c,c⊕a)=(3,6,5) are the sides of a non-degenerate triangle.
- The triple (a,b,c)=(1,2,4) is valid because (a⊕b,b⊕c,c⊕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, 110111111010100102=114514. The full answer (before taking the modulo) is 1466408118808164.
在第一个测试用例中,1012=5。
- 三元组 (a,b,c)=(0,3,5) 是合法的,因为 (a⊕b,b⊕c,c⊕a)=(3,6,5) 可构成一个非退化三角形的三条边。
- 三元组 (a,b,c)=(1,2,4) 是合法的,因为 (a⊕b,b⊕c,c⊕a)=(3,6,5) 可构成一个非退化三角形的三条边。
上述两个三元组各自的 6 种排列构成了全部合法三元组,因此答案为 12。
在第三个测试用例中,110111111010100102=114514。完整答案(取模前)为 1466408118808164。
输入解题思路,AI测评打分。不知道怎么写?