CF1147D.Palindrome XOR

提高+/省选-

通过率:0%

时间限制:1.00s

内存限制:256MB

AC君温馨提醒

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

题目描述

You are given a string ss consisting of characters "1", "0", and "?". The first character of ss is guaranteed to be "1". Let mm be the number of characters in ss.

Count the number of ways we can choose a pair of integers a,ba, b that satisfies the following:

  • 1≤a<b<2m1 \leq a \lt b \lt 2^m
  • When written without leading zeros, the base-2 representations of aa and bb are both palindromes.
  • The base-2 representation of bitwise XOR of aa and bb matches the pattern ss. We say that tt matches ss if the lengths of tt and ss are the same and for every ii, the ii-th character of tt is equal to the ii-th character of ss, or the ii-th character of ss is "?".

Compute this count modulo 998244353998244353.

给你一个由字符 "1"、"0" 和 "?" 组成的字符串 ss,其中 ss 的第一个字符保证为 "1"。设 mm 为字符串 ss 的长度。

请计算满足以下条件的整数对 (a,b)(a, b) 的个数:

  • 1≤a<b<2m1 \leq a \lt b \lt 2^m;
  • aa 和 bb 的二进制表示(不含前导零)均为回文串;
  • aa 与 bb 的按位异或(XOR)结果的二进制表示与模式 ss 匹配。我们称字符串 tt 与 ss 匹配,当且仅当 tt 与 ss 长度相同,且对每个下标 ii,tt 的第 ii 个字符等于 ss 的第 ii 个字符,或者 ss 的第 ii 个字符为 "?"。

请将该计数值对 998244353998244353 取模后输出。

输入格式

The first line contains a single string ss (1≤∣s∣≤1 0001 \leq |s| \leq 1\,000). ss consists only of characters "1", "0" and "?". It is guaranteed that the first character of ss is a "1".

第一行包含一个字符串 ss(1≤∣s∣≤1 0001 \leq |s| \leq 1\,000)。ss 仅由字符 "1"、"0" 和 "?" 组成。保证 ss 的第一个字符为 "1"。

输出格式

Print a single integer, the count of pairs that satisfy the conditions modulo 998244353998244353.

输出一个整数,即满足条件的数对个数对 998244353998244353 取模的结果。

输入输出样例

  • 输入#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)(111, 10001), (11, 10101), (1001, 11111).

对于第一个例子,二进制下的数对为 (111,10001),(11,10101),(1001,11111)(111, 10001), (11, 10101), (1001, 11111)。

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

首页