题目描述
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$.