Ignore Submasks
Time limit1sMemory limit512 MB
For each k-bit mask x, find the first array element that does not contain x as a submask, and sum these indices modulo 998244353.
- Level
Hard8 of 10
- Topics
- Bit manipulation, Dynamic programming, Combinatorics, Math
- Solved
- No attempts yet
Problem
You are given an array of integers, . Each integer is between 0 and , inclusive.
Let be the smallest such that , or 0 if there is no such . Here is the bitwise AND operation.
Find . This value may be very large, so find it modulo .
Input
The first line contains two integers , (, ).
The next line contains integers ().
Output
Print modulo .
Notes
In the first example, and .
In the second example, , , , and .