#P98. [NOI 2025 Day 2] 集合
[NOI 2025 Day 2] 集合
Person in Charge
Problem Description
Little X has numbers labeled from to , where the -th () number is .
For a subset , define as the bitwise AND of all numbers in . Specifically, if is empty, then .
Define an ordered pair of subsets of (which can be empty) as special if and only if and . The weight of the ordered pair is defined as the product of all numbers whose labels are included in , i.e., . Specifically, if , the weight of is .
Little X wants to know the sum of the weights of all special ordered pairs. Please help him compute this value. Since the answer may be large, you only need to output the result modulo .
Input Format
This problem contains multiple test cases.
The first line of input contains two non-negative integers , representing the test case ID and the number of test cases, respectively. indicates that the test case is a sample.
For each test case:
- The first line contains a positive integer , indicating there are numbers.
- The second line contains non-negative integers .
Output Format
For each test case, output one line containing an integer, representing the sum of the weights of all special ordered pairs modulo .
Samples
0 2
2
1 2 3 4
3
1 1 1 1 1 1 1 1
117
2091
Sample 2
See set/set2.in and set/set2.ans in the contestant directory.
This sample satisfies the constraints of Test Case 2.
Sample 3
See set/set3.in and set/set3.ans in the contestant directory.
This sample satisfies the constraints of Test Case 3.
Sample 4
See set/set4.in and set/set4.ans in the contestant directory.
This sample satisfies the constraints of Test Case 9.
Data Range
For all test data, the following guarantees hold:
- ;
- ;
- For all , .
| Test Case ID | Special Properties | |
|---|---|---|
| B | ||
| None | ||
| B | ||
| None | ||
| B | ||
| None | ||
| B | ||
| None | ||
| B | ||
| None | ||
| AB | ||
| A | ||
| B | ||
| None |
- Special Property A: At most indices satisfy .
- Special Property B: For all , .