AT_ndpc2026_m.Numeral
入门
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given a string S of length 2N consisting of characters 1, 2, …, 9.
For each non-negative integer n such that 0≤n≤2N−1, define f(n) as follows:
- List all non-negative integers i such that n OR i=n, and sort them in increasing order. Let them be i1,i2,…,ik. Here, OR denotes the bitwise OR operation.
- Let T be the string formed by taking the (i1+1)-th, (i2+1)-th, …, (ik+1)-th characters of S in this order.
- Interpret T as a decimal integer, and let its value be X. Then define f(n)=Xmod998244353.
Compute all values f(0),f(1),…,f(2N−1), and output the value of the following expression. Here, XOR denotes the bitwise exclusive OR operation.
n=0∑2N−1(f(n) XOR n)
给定一个长度为 2N 的字符串 S,其字符仅由 1、2、…、9 组成。
对每个满足 0≤n≤2N−1 的非负整数 n,定义函数 f(n) 如下:
- 列出所有满足 n OR i=n 的非负整数 i,并将它们按升序排列,记为 i1,i2,…,ik。其中 OR 表示按位或(bitwise OR)运算。
- 构造字符串 T,其字符依次为 S 的第 (i1+1) 个、第 (i2+1) 个、…、第 (ik+1) 个字符。
- 将 T 解释为一个十进制整数,记其值为 X;然后定义 f(n)=Xmod998244353。
请计算所有 f(0),f(1),…,f(2N−1) 的值,并输出下列表达式的值。其中 XOR 表示按位异或(bitwise exclusive OR)运算。
n=0∑2N−1(f(n) XOR n)
输入格式
The input is given from standard input in the following format:
N
S
输入从标准输入按以下格式给出:
N
S
输出格式
Print n=0∑2N−1(f(n) XOR n).
输出 n=0∑2N−1(f(n) XOR n)。
输入输出样例
输入#1
2 1234
输出#1
1262
输入#2
4 6415986517946482
输出#2
790534415
说明/提示
Sample 1 Explanation:
For all n such that 0≤n≤2N−1, the values of f(n) are:
- When n=0, f(n)=1
- When n=1, f(n)=12
- When n=2, f(n)=13
- When n=3, f(n)=1234
Therefore, output (1 XOR 0)+(12 XOR 1)+(13 XOR 2)+(1234 XOR 3)=1+13+15+1233=1262.
Constraints
- 1≤N≤22
- S is a string of length 2N consisting of
1,2, …,9
样例 1 解释:
对于所有满足 0≤n≤2N−1 的 n,函数 f(n) 的取值如下:
- 当 n=0 时,f(n)=1
- 当 n=1 时,f(n)=12
- 当 n=2 时,f(n)=13
- 当 n=3 时,f(n)=1234
因此,输出结果为 (1 XOR 0)+(12 XOR 1)+(13 XOR 2)+(1234 XOR 3)=1+13+15+1233=1262。
限制条件
- 1≤N≤22
- S 是一个长度为 2N 的字符串,仅由字符
1、2、…、9组成
输入解题思路,AI测评打分。不知道怎么写?