A15175 | XOR Triangle
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
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](https://en.wikipedia.org/wiki/Bitwise_operation#XOR).
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>z$ , $x+z>y$ , and $y+z>x$ .
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](https://en.wikipedia.org/wiki/Bitwise_operation#XOR).
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>z$ , $x+z>y$ , and $y+z>x$ .
输入格式
The first and only line contains the binary representation of an integer $n$ ( $0 < n < 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$ .
For example, the string 10 is the binary representation of the number $2$ , while the string 1010 represents the number $10$ .
输出格式
Print one integer — the number of triples $(a,b,c)$ satisfying the conditions described in the statement modulo $998\,244\,353$ .
输入输出样例
输入 #1
101
输出 #1
12
输入 #2
1110
输出 #2
780
输入 #3
11011111101010010
输出 #3
141427753
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$ .
- 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$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted