Convolution
Time limit2sMemory limit1024 MB
Compute the union convolution H(A) = sum of F(B)G(C) over B union C = A for arrays from a PRNG, then print a weighted checksum mod 2^32.
- Level
Medium4 of 10
- Topics
- Bit manipulation, Math
- Solved
- No attempts yet
Problem
Consider all subsets of the set . Each subset corresponds to a unique integer . A function on an -element set is given by an integer array of length , and .
You are given two functions and . Find the function such that
Input
The first line contains two integers and (, ). Here is the size of , and is the number of test cases.
The second line contains two integers and , each from to . They are used in the following pseudo-random generator:
1. unsigned int cur = 0; // unsigned 32-bit integer
2. unsigned int nextRand16() {
3. cur = cur * a + b; // calculated modulo 2^32
4. return cur / 2^16; // integer from 0 to 2^16-1
5. }
The test cases are generated in order. In each one, first generate the elements of in increasing index order, then the elements of in the same order. Each element is produced by calling nextRand16().
Output
For each test case, print one integer on its own line: .
Hint
The arrays for the first example are:
- : 3, 113, 3395, 36331, 41370, 61471, 9130, 11774
- : 25547, 45526, 55066, 13590, 14501, 41817, 9356, 18543
- : 76641, 8167827, 273846333, 5284992017, 1656829263, 11450721456, 3699971823, 14260048942
- : 32024, 43238, 51978, 52034, 53714, 38578, 43250, 52338
- : 62834, 50034, 59250, 8050, 44914, 36722, 53106, 20338
- : 2012196016, 6482475400, 8243104152, 15561662464, 7225902008, 16869349792, 22350138288, 44342816072