영어 원문입니다. 원문의 수식·표를 글자로 옮겨 모양이 다를 수 있습니다. 정확한 내용은 원문 페이지에서 확인하세요. 원문 페이지 열기 (새 창)
시간 제한 1초 · 메모리 제한 512 MB
Problem
You are given an array of n integers. Your task is to calculate the bitwise xor of each window of k elements, from left to right.
In this problem the input data is large and it is created using a generator.
Input
The first line contains two integers n and k: the number of elements and the size of the window.
The next line contains four integers x, a, b and c: the input generator parameters. The input is generated as follows:
- x_1=x
- x_i=(ax_{i-1}+b) mod c for i=2,3,…,n
Output
Print the xor of all window xors.
Constraints
- 1 ≤ k ≤ n ≤ 10^7
- 0 ≤ x, a, b ≤ 10^9
- 1 ≤ c ≤ 10^9
Example
Explanation: The input array is [3,0,1,8,2,4,7,6]. The windows are [3,0,1,8,2], [0,1,8,2,4], [1,8,2,4,7] and [8,2,4,7,6], and their xors are 8, 15, 8 and 15. Thus, the answer is 8 ⊕ 15 ⊕ 8 ⊕ 15 = 0.
예제
예제 1
8 5 3 7 1 11
0