P25423 [AtCoder] Loto 2
提高-
题目描述

Problem Description

$ N $ cards are arranged in a row, and the $i(1 \leq i \leq N)$ card has an integer $ A_i $ written on it.

There is a lottery called Loto 2 using these $ N $ cards. Loto 2 involves selecting two different numbers $ i, j (i < j) $ from the numbers 1 to $ N $, and winning if the product of the values written on the selected cards $ A_i A_j $ is a multiple of $ K $.

We call a combination of $ i $ and $ j $ such that $ A_i A_j $ is a multiple of $ K $ a good combination. Find the number of good combinations.

Input Format

The input is given from the standard input in the following format:

$ N $ $ K $ $ A_1 $ $ A_2 $ $ … $ $ A_N $

Output Format

Output the total number of good combinations in one line.

Sample Input and Output

Sample Input #1

4 6
1 3 2 6

Sample Output #1

4

Sample Input #2

5 1
1 2 3 1 2

Sample Output #2

10

Sample Input #3

12 60
38 19 180 222 560 1000 7 99 845 3600 12 90

Sample Output #3

33

Notes/Hints

Constraints

  • $1 \leq N \leq 200,000$
  • $1 \leq A_i \leq 10^{9} (1 \leq i \leq N)$
  • $1 \leq K \leq 10^{9}$
  • $ A_i, K $ are all integers

Sample Explanation 1

The $ 4 $ good combinations are $ (1, 4), (2, 3), (2, 4), (3, 4) $.

Sample Explanation 2

Any combination of two numbers forms a good combination.

输入格式

见题面 Input 部分

输出格式

见题面 Output 部分

样例输入
4 6 1 3 2 6
样例输出
4