#P3917. 异或序列

    ID: 2854 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 6 上传者: 标签>数学枚举,暴力进制概率论,统计

异或序列

Description

Given a sequence A1,A2,,ANA_1, A_2, \cdots, A_N, compute

$$\sum_{1\le i\le j\le N} A_i\oplus A_{i+1}\oplus\cdots\oplus A_j$$

where \bigoplus denotes bitwise XOR.

Input Format

The first line contains an integer NN.

The second line contains NN integers A1,A2,,ANA_1, A_2, \cdots, A_N.

Output Format

Output a single integer: the value of the expression.

2
1 2
6

Hint

  • For 60%60\% of the testdata, 1N1031 \le N \le 10^3.
  • For 100%100\% of the testdata, 1N1051 \le N \le 10^5, 0Ai1090 \le A_i \le 10^9.

Translated by ChatGPT 5