#P8034. [COCI 2015/2016 #7] Ozljeda
[COCI 2015/2016 #7] Ozljeda
Problem Description
You are given a sequence with elements. Now define an infinite sequence as follows:
$$x_n=\begin{cases} a_n, & 1 \le n \le K, \cr \bigoplus_{i=n-1}^{n-K} x_i, & n > K \end{cases}$$You are given queries . For each query, find the value of .
Input Format
The first line contains an integer .
The second line contains integers .
The third line contains an integer .
The next lines each contain two integers .
Output Format
Output lines. Each line contains the answer to the corresponding query.
4
1 3 5 7
3
2 2
2 5
1 5
3
1
0
5
3 3 4 3 2
4
1 2
1 3
5 6
7 9
0
4
7
4
Hint
Constraints
- For of the testdata, , , , .
Hints and Notes
This problem is translated from COCI 2015-2016 #7 Task 3 Ozljeda.
The score for this problem follows the original COCI settings, with a full score of .
Translated by ChatGPT 5