#P3794. Subarray GCD XOR OR

    ID: 17044 Type: Default 1000ms 256MiB

Subarray GCD XOR OR

Subarray GCD XOR OR

You are given a sequence of n positive integers \([a_1, a_2, \cdots, a_n]\). Your task is to count the number of pairs \((i,j)\) such that \(1 \le i \le j \le n\) and

[ \gcd(a_i, a_{i+1}, \ldots, a_j) \oplus (a_i \lor a_{i+1} \lor \cdots \lor a_j) = k, ]

where \(\oplus\) denotes the bitwise XOR operation and \(\lor\) denotes the bitwise OR operation.

Note that all numbers in the sequence are positive integers.

inputFormat

The first line contains two integers \(n\) and \(k\) separated by a space.

The second line contains \(n\) positive integers \(a_1, a_2, \ldots, a_n\) separated by spaces.

outputFormat

Output a single integer representing the number of pairs \((i, j)\) satisfying the condition.

sample

3 0
1 1 1
6