PHƯỚC HƯNG OJ · THỬ THÁCH THUẬT TOÁN

#GL0000234. Đếm cặp có tích là lũy thừa bậc k (Power Products)

HỌC THEO LỘ TRÌNH

Bài tập thuộc lộ trình

1 lộ trình

Đếm cặp có tích là lũy thừa bậc k (Power Products)

Đếm cặp có tích là lũy thừa bậc k (Power Products)

Source: Codeforces

Version: Phuoc Hung OJ Extended

Problem Statement

Given nn positive integers and k≥2k\ge2, count pairs i<ji<j whose product is a perfect kk-th power.

Input

  • First line: n,kn,k.
  • Second line: nn integers aia_i.

Output

Print the number of qualifying pairs.

Subtasks

  • Subtask 1 (20 points): 2≤n≤20, 2≤k≤5, 1≤ai≤1002\le n\le20,\ 2\le k\le5,\ 1\le a_i\le100.
  • Subtask 2 (30 points): 2≤n≤3000, 2≤k≤10, 1≤ai≤50002\le n\le3000,\ 2\le k\le10,\ 1\le a_i\le5000.
  • Subtask 3 (50 points): 2≤n≤105, 2≤k≤100, 1≤ai≤1052\le n\le10^5,\ 2\le k\le100,\ 1\le a_i\le10^5.

Examples

Example 1

Input

6 3
1 3 9 8 24 1

Output

5

Explanation

Exactly five pairs have a product that is a perfect cube.

Example 2

Input

2 2
2 8

Output

1

Explanation

The product is 2⋅8=16=422\cdot8=16=4^2.