#P3794. 签到题IV

    ID: 2732 远端评测题 1000ms 125MiB 尝试: 0 已通过: 0 难度: 7 上传者: 标签>线段树洛谷原创O2优化枚举,暴力进制洛谷月赛

签到题IV

Description

Given a sequence of length nn, [a1,a2,,an][a_1, a_2, \ldots, a_n], where each number is a positive integer.

You need to find how many pairs (i,j)(i, j) satisfy 1ijn1 \le i \le j \le n and $\gcd(a_i, a_{i+1}, \ldots, a_j) \operatorname{xor} (a_i \operatorname{or} a_{i+1} \operatorname{or} \cdots \operatorname{or} a_j) = k$, where xor\operatorname{xor} denotes bitwise XOR and or\operatorname{or} denotes bitwise OR.

Input Format

The first line contains two integers nn and kk.

The second line contains nn integers a1,a2,,ana_1, a_2, \cdots, a_n.

Output Format

Output the number of valid pairs (i,j)(i, j).

5 6
2 4 3 4 2
8

Hint

  • For 30%30\% of the testdata, n500n \le 500.
  • For 60%60\% of the testdata, n100000n \le 100000.
  • For 100%100\% of the testdata, 1n,ai5000001 \le n, a_i \le 500000.

Translated by ChatGPT 5