AtCoder Beginner Contest 098
D
Xor Sum 2
AtCoder
⌀ 1404
原题
← C→
翻译中…

Problem Statement

翻译中…

There is an integer sequence $A$ of length $N$.

翻译中…

Find the number of the pairs of integers $l$ and $r$ ($1 \leq l \leq r \leq N$) that satisfy the following condition:

翻译中…
  • $A_l\ xor\ A_{l+1}\ xor\ ...\ xor\ A_r = A_l\ +\ A_{l+1}\ +\ ...\ +\ A_r$
翻译中…

Here, $xor$ denotes the bitwise exclusive OR.

翻译中…

Definition of XOR The XOR of integers $c_1, c_2, ..., c_m$ is defined as follows: Let the XOR be $X$. In the binary representation of $X$, the digit in the $2^k$'s place ($0 \leq k$; $k$ is an integer) is $1$ if there are an odd number of integers among $c_1, c_2, ...c_m$ whose binary representation has $1$ in the $2^k$'s place, and $0$ if that number is even. For example, let us compute the XOR of $3$ and $5$. The binary representation of $3$ is $011$, and the binary representation of $5$ is $101$, thus the XOR has the binary representation $110$, that is, the XOR is $6$.

翻译中…

Constraints

翻译中…
  • $1 \leq N \leq 2 \times 10^5$
  • $0 \leq A_i < 2^{20}$
  • All values in input are integers.
翻译中…

Input

翻译中…

Input is given from Standard Input in the following format:

翻译中…

N
A_1 A_2 ... A_N

翻译中…

Output

翻译中…

Print the number of the pairs of integers $l$ and $r$ ($1 \leq l \leq r \leq N$) that satisfy the condition.

翻译中…

样例

Input #1
4
2 5 4 6
Output #1
5
$(l,r)=(1,1),(2,2),(3,3),(4,4)$ clearly satisfy the condition. $(l,r)=(1,2)$ also satisfies the condition, since $A_1\ xor\ A_2 = A_1\ +\ A_2 = 7$. There are no other pairs that satisfy the condition, so the answer is $5$.
Input #2
9
0 0 0 0 0 0 0 0 0
Output #2
45
Input #3
19
885 8 1 128 83 32 256 206 639 16 4 128 689 32 8 64 885 969 1
Output #3
37
题目信息
题号
arc098_b
时间限制
2 s
内存限制
1024 MB

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