D - Anticube Editorial /

Time Limit: 5 sec / Memory Limit: 256 MB

配点 : 11001100

問題文

高橋君は誕生日にお母さんから正の整数 s1,...,sNs_1,...,s_N をもらいました。ただし、要素の重複は許されます。 高橋君は、これらのNN個の整数のうちのいくつかを丸で囲みます。

高橋君は立方数が嫌いなので、si,sj(ij)s_i,s_j(i ≠ j)の両方が丸で囲まれているなら、その積sisjs_is_jは立方数とならないようにしたいです。 例えば、s1=1,s2=1,s3=2,s4=4s_1=1,s_2=1,s_3=2,s_4=4のとき、s1s_1s2s_2を同時に丸で囲むことはできません。また、s3s_3s4s_4を同時に丸で囲むこともできません。

高橋君が丸で囲むことができる整数の個数の最大値を求めてください。

制約

  • 1N1051 ≦ N ≦ 10^5
  • 1si10101 ≦ s_i ≦ 10^{10}
  • 入力はすべて整数である。

入力

入力は以下の形式で標準入力から与えられる。

NN
s1s_1
:
sNs_N

出力

高橋君が丸で囲むことができる整数の個数の最大値を表す整数を出力せよ。


入力例 1Copy

Copy
8
1
2
3
4
5
6
7
8

出力例 1Copy

Copy
6

1,2,3,5,6,71,2,3,5,6,7 を丸で囲むことができます。


入力例 2Copy

Copy
6
2
4
8
16
32
64

出力例 2Copy

Copy
3

入力例 3Copy

Copy
10
1
10
100
1000000007
10000000000
1000000009
999999999
999
999
999

出力例 3Copy

Copy
9

Score : 11001100 points

Problem Statement

Snuke got positive integers s1,...,sNs_1,...,s_N from his mother, as a birthday present. There may be duplicate elements.

He will circle some of these NN integers. Since he dislikes cubic numbers, he wants to ensure that if both sis_i and sj(ij)s_j (i ≠ j) are circled, the product sisjs_is_j is not cubic. For example, when s1=1,s2=1,s3=2,s4=4s_1=1,s_2=1,s_3=2,s_4=4, it is not possible to circle both s1s_1 and s2s_2 at the same time. It is not possible to circle both s3s_3 and s4s_4 at the same time, either.

Find the maximum number of integers that Snuke can circle.

Constraints

  • 1N1051 ≦ N ≦ 10^5
  • 1si10101 ≦ s_i ≦ 10^{10}
  • All input values are integers.

Input

The input is given from Standard Input in the following format:

NN
s1s_1
:
sNs_N

Output

Print the maximum number of integers that Snuke can circle.


Sample Input 1Copy

Copy
8
1
2
3
4
5
6
7
8

Sample Output 1Copy

Copy
6

Snuke can circle 1,2,3,5,6,71,2,3,5,6,7.


Sample Input 2Copy

Copy
6
2
4
8
16
32
64

Sample Output 2Copy

Copy
3

Sample Input 3Copy

Copy
10
1
10
100
1000000007
10000000000
1000000009
999999999
999
999
999

Sample Output 3Copy

Copy
9


2025-03-15 (Sat)
03:20:32 +00:00