RoAlgo Contest #6 | sugubatz

This was the problem page during the contest. Access the current page here.
Time limit: 0.6s Memory limit: 30MB Input: Output:

Cosmin was bored during the Romanian class when the teacher mentioned a mischievous character in the story "Povestea lui Harap-Alb." This reminded Cosmin of a tricky problem he couldn't solve. If you help him solve the problem, he will send you a mischievous elf with a violin and a bow. Thus, Cosmin will understand how to solve the problem, and you will enjoy harmonious music.

Task

You are given two numbers, NN and XX, followed by an array AA of NN non-zero natural numbers, indexed from 11 to NN. A new array BB will be constructed, where each number bib_i (1iN1 \leq i \leq N) takes the largest value of the greatest common divisor that aia_i has with another number in the array AA. Determine the number of subarrays in array BB whose bitwise "OR" sum is greater than or equal to the number XX.

A subarray of array BB is a sequence of elements from different, consecutive positions.

The bitwise "OR" sum of a subarray v1,v2,,vkv_1, v_2, \dots, v_k is defined as v1v2vkv_1 \vert v_2 \vert \dots \vert v_k, where \vert signifies the bitwise "OR" operator.

Input data

The first line contains the natural numbers NN and XX, and the second line contains the NN natural numbers of the array AA. The numbers on the same line are separated by a space.

Output data

Print a single number representing the number of subarrays with the desired property.

Constraints and clarifications

  • 2N1 000 0002 \leq N \leq 1 \ 000 \ 000
  • 1X1 000 0001 \leq X \leq 1 \ 000 \ 000
  • 1ai1 000 0001 \leq a_i \leq 1 \ 000 \ 000
# Points Constraints
1 22 2N1 0002 \leq N \leq 1 \ 000
2 31 2N100 0002 \leq N \leq 100 \ 000
3 47 No additional constraints

Note

Due to the very large input data, use the following instructions at the beginning of the main() function in your C++ program:

ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);

Example

stdin

5 3
17 2 9 12 2

stdout

12

Explanation

After each number bib_i (1iN1 \leq i \leq N) takes the largest value of the greatest common divisor that aia_i has with another number in array AA, the array BB has values 1,2,3,3,21, 2, 3, 3, 2. In this new array, there are 1212 subarrays that have a bitwise "OR" sum greater than or equal to 33.

Log in or sign up to be able to send submissions!