Codeforces Round 1007 (Div. 2)
D1
Infinite Sequence (Easy Version)
Codeforces
1800
原题
← CD2 →
翻译中…

This is the easy version of the problem. The difference between the versions is that in this version, $l=r$. You can hack only if you solved all versions of this problem.

翻译中…

You are given a positive integer $n$ and the first $n$ terms of an infinite binary sequence $a$, which is defined as follows:

翻译中…
  • For $m \gt n$, $a_m = a_1 \oplus a_2 \oplus \ldots \oplus a_{\lfloor \frac{m}{2} \rfloor}$$^{\text{∗}}$.
翻译中…

Your task is to compute the sum of elements in a given range $[l, r]$: $a_l + a_{l + 1} + \ldots + a_r$.

翻译中…

$^{\text{∗}}$$\oplus$ denotes the bitwise XOR operation.

翻译中…

Input

翻译中…

Each test contains multiple test cases. The first line contains the number of test cases $t$ ($1 \le t \le 10^4$). The description of the test cases follows.

翻译中…

The first line of each test case contains three integers $n$, $l$, and $r$ ($1 \le n \le 2 \cdot 10^5$, $1 \le l=r\le 10^{18}$).

翻译中…

The second line contains $n$ integers $a_1, a_2, \ldots, a_n$ ($\color{red}{a_i \in \{0, 1\}}$) — the first $n$ terms of the sequence $a$.

翻译中…

It is guaranteed that the sum of $n$ over all test cases does not exceed $2 \cdot 10^5$.

翻译中…

Output

翻译中…

For each test case, output a single integer — the sum of elements in the given range.

翻译中…

Note

翻译中…

In the first test case, the sequence $a$ is equal to $$[\underline{\color{red}{1}}, 1, 1, 0, 0, 1, 1, 1, 1, 1, \ldots]$$ where $l = 1$, and $r = 1$. The sum of elements in the range $[1, 1]$ is equal to $$a_1 = 1.$$

翻译中…

In the second test case, the sequence $a$ is equal to $$[\color{red}{1}, \color{red}{0}, \underline{1}, 1, 1, 0, 0, 1, 1, 0, \ldots]$$ where $l = 3$, and $r = 3$. The sum of elements in the range $[3, 3]$ is equal to $$a_3 = 1.$$

翻译中…

样例

Input #1
9
1 1 1
1
2 3 3
1 0
3 5 5
1 1 1
1 234 234
0
5 1111 1111
1 0 1 0 1
1 1000000000000000000 1000000000000000000
1
10 87 87
0 1 1 1 1 1 1 1 0 0
12 69 69
1 0 0 0 0 1 0 1 0 1 1 0
13 46 46
0 1 0 1 1 1 1 1 1 0 1 1 1
Output #1
1
1
0
0
1
0
1
0
0
InputCopy OutputCopy
题目信息
题号
2071D1
时间限制
2 s
内存限制
256 MB
标签
位运算
暴力
动态规划
模拟
数学

题面与样例版权归 Codeforces 及出题人所有;中文翻译由 AI 生成(CI 管线),如有出入请以原文为准。