A. brute 二等功

    Type: Default File IO: edg 2000ms 512MiB

brute 二等功

You cannot submit for this problem because the contest is ended. You can click "Open in Problem Set" to view this problem in normal mode.

题目描述

有 2n2^n 个数,编号为 00 到 2n−12^n-1,编号 ii 对应的数值为 aia_i。

对于编号集合 SS,定义 f(S)f(S) 为集合内所有编号的二进制按位与。特别地,f(∅)=2n−1f(\varnothing)=2^n-1。

选择两个编号集合 P,QP,Q,它们可以为空,且必须满足 P∩Q=∅P\cap Q=\varnothing、f(P)=f(Q)f(P)=f(Q)。这是一个有序对,交换 P,QP,Q 后一般是另一种方案。

每种方案的权值为:

∏i∈P∪Qai.\prod_{i\in P\cup Q}a_i.

当两个集合都为空时,权值为 11。求所有合法有序对的权值之和,对 998244353998244353 取模。

输入格式

从文件 edg.in 读入。

第一行一个整数 TT,表示数据组数。每组数据先输入一行整数 nn,再输入一行 2n2^n 个整数 a0,a1,…,a2n−1a_0,a_1,\ldots,a_{2^n-1}。

输出格式

输出到文件 edg.out。每组数据输出一行一个整数,表示答案。

数据范围

对于 100% 的数据,1≤T≤31\le T\le3,2≤n≤62\le n\le6,0≤ai<9982443530\le a_i<998244353。

没有额外特殊性质,允许 ai=998244352a_i=998244352。本题共 20 个等分测试点,每点 5 分。

样例 1

输入:

2
2
1 2 3 4
3
1 1 1 1 1 1 1 1

输出:

117

2091

其他下发样例见题目附件 samples.zip。其中的输入和答案均符合本版数据范围。

样例 1 的两组答案分别为 117 和 2091。注意:按位与使用编号,权值乘积使用数值。

20261022-赛后改题(部分分)

Not Claimed
Status
Done
Problem
4
Open Since
2026-10-22 14:00
Deadline
2026-10-30 23:59
Extension
24 hour(s)