【Atcoder - AGC003D】Anticube


@Problem Statement@

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

He will circle some of these N integers. Since he dislikes cubic numbers, he wants to ensure that if both si and sj(i≠j) are circled, the product si*sj is not cubic. For example, when s1=1,s2=1,s3=2,s4=4, it is not possible to circle both s1 and s2 at the same time. It is not possible to circle both s3 and s4 at the same time, either.

Find the maximum number of integers that Snuke can circle.

Constraints
1≦N≦10^5
1≦si≦10^10
All input values are integers.

Input
The input is given from Standard Input in the following format:
N
s1
:
sN
Output
Print the maximum number of integers that Snuke can circle.

Sample Input 1
8
1
2
3
4
5
6
7
8
Sample Output 1
6
Snuke can circle 1,2,3,5,6,7.

Sample Input 2
6
2
4
8
16
32
64
Sample Output 2
3

Sample Input 3
10
1
10
100
1000000007
10000000000
1000000009
999999999
999
999
999
Sample Output 3
9

@Translation@

Snuke 收到了一份特殊的生日礼物:N 个正整数!
Snuke 认为两个数是“不相配”的,当且仅当这两个数的乘积为立方数。
现在 Snuke 想要从 N 个数中选出尽量多的数,使得这些数两两“相配”。

@Solution@

首先,可以想到的第一个操作肯定是把每一个数的立方因子去掉。

然后从唯一分解式考虑:令 x = p 1 a 1 ∗ p 2 a 2 ∗ . . . ∗ p k a k x = p_1^{a_1}*p_2^{a_2}*...*p_k^{a_k} x=p1a1p2a2...pkak
去掉立方因子得到: x ′ = p 1 a 1 m o d    3 ∗ p 2 a 2 m o d    3 ∗ . . . ∗

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值