A12515 | Palindrome XOR
时间限制1s
内存限制256MB
通过 / 提交0/0
题目描述
You are given a string $s$ consisting of characters "1", "0", and "?". The first character of $s$ is guaranteed to be "1". Let $m$ be the number of characters in $s$ .
Count the number of ways we can choose a pair of integers $a, b$ that satisfies the following:
- $1 \leq a < b < 2^m$
- When written without leading zeros, the base-2 representations of $a$ and $b$ are both palindromes.
- The base-2 representation of bitwise XOR of $a$ and $b$ matches the pattern $s$ . We say that $t$ matches $s$ if the lengths of $t$ and $s$ are the same and for every $i$ , the $i$ -th character of $t$ is equal to the $i$ -th character of $s$ , or the $i$ -th character of $s$ is "?".
Compute this count modulo $998244353$ .
Count the number of ways we can choose a pair of integers $a, b$ that satisfies the following:
- $1 \leq a < b < 2^m$
- When written without leading zeros, the base-2 representations of $a$ and $b$ are both palindromes.
- The base-2 representation of bitwise XOR of $a$ and $b$ matches the pattern $s$ . We say that $t$ matches $s$ if the lengths of $t$ and $s$ are the same and for every $i$ , the $i$ -th character of $t$ is equal to the $i$ -th character of $s$ , or the $i$ -th character of $s$ is "?".
Compute this count modulo $998244353$ .
输入格式
The first line contains a single string $s$ ( $1 \leq |s| \leq 1\,000$ ). $s$ consists only of characters "1", "0" and "?". It is guaranteed that the first character of $s$ is a "1".
输出格式
Print a single integer, the count of pairs that satisfy the conditions modulo $998244353$ .
输入输出样例
输入 #1
10110
输出 #1
3
输入 #2
1?0???10
输出 #2
44
输入 #3
1?????????????????????????????????????
输出 #3
519569202
输入 #4
1
输出 #4
0
For the first example, the pairs in base-2 are $(111, 10001), (11, 10101), (1001, 11111)$ .
C++ 编辑器
输入
输出
可保存默认模板;新题优先使用已保存模板。
当前快捷键仅展示,暂不支持修改。
- 撤销
Ctrl / ⌘ + Z - 重做
Ctrl / ⌘ + Y - 查找
Ctrl / ⌘ + F - 全选
Ctrl / ⌘ + A - 复制
Ctrl / ⌘ + C - 剪切
Ctrl / ⌘ + X - 粘贴
Ctrl / ⌘ + V - 自动排版
工具栏排版按钮 - 草稿保存
编辑时自动保存到本机
历史
提交记录
状态说明时间源码
AI
作答助手
你好,我是作答助手。可以问思路、复杂度、样例含义或代码报错原因;不会直接给出完整 AC 代码。
确定要清空代码吗?
提交通过
评测结果:Accepted