Convolution
시간 제한2초메모리 제한1024 MB
n개 원소 집합의 모든 부분집합에 대한 값 f와 g가 주어질 때, B ∪ C = A인 모든 B, C에 대해 f(B)g(C)를 더한 부분집합 합성곱 h(A)를 구한 뒤 각 테스트 케이스마다 하나의 검증값을 출력한다.
문제
Consider all subsets of set . Every subset corresponds to a unique integer . Let function of an -element set be defined by an array of integers of length : the value is equal to .
You are given two functions and . Your task is to find such function that
입력
The first line contains two integers and (, ). Here, is the size of the set , and is number of test cases. The second line contains two integers and , each from to . These numbers 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 232
4. return cur / 216; // integer from 0 to 216-1
5. }
The test cases are generated successively. In each of them, first, you must generate the elements of array (values of ) in the order of increasing array index, and after that, you must generate the elements of (values of ) in the same order. Each element is generated by calling the function nextRand16().
출력
For each test case, print one integer on a separate line:
힌트
The arrays in the first example are the following: