示例#1
0
文件: 848040.cs 项目: qifanyyy/CLCDSA
        public void Solve()
        {
            var n      = sc.Integer();
            var primes = MathEx.Sieve(200000);
            var a      = sc.Long(n);
            var map    = new SortedMap <long, int>();
            var pp     = MathEx.SieveList(2200);

            foreach (long p in pp)
            {
                var q = p * p * p;
                for (int i = 0; i < n; i++)
                {
                    while (a[i] % q == 0)
                    {
                        a[i] /= q;
                    }
                }
            }
            Debug.WriteLine(a.AsJoinedString());
            var used = new HashSet <long>();

            foreach (var x in a)
            {
                map[x]++;
            }

            var        ans   = 0;
            const long otaku = 10000000001;

            foreach (var x in map)
            {
                var y = x.Key;
                if (y == 1)
                {
                    ans++; continue;
                }
                if (used.Contains(y))
                {
                    continue;
                }
                Debug.WriteLine(x);
                var inv = 1L;
                foreach (long p in pp)
                {
                    var q = p * p;
                    if (y % q == 0)
                    {
                        inv = Math.Min(otaku, inv * p); y /= q;
                    }
                    else if (y % p == 0)
                    {
                        inv = Math.Min(otaku, inv * p);
                        inv = Math.Min(otaku, inv * p);
                        y  /= p;
                    }
                }

                var u = x.Value;
                if (y != 1)
                {
                    if (y < 200000 && primes[y])
                    {
                        inv = Math.Min(otaku, inv * y);
                        inv = Math.Min(otaku, inv * y);
                        y   = 1;
                    }
                    else
                    {
                        inv = otaku;
                    }
                }
                int v;
                if (map.TryGetValue(inv, out v))
                {
                    ans += Math.Max(u, v);
                    used.Add(inv);
                }
                else
                {
                    ans += u;
                }

                used.Add(x.Key);
            }
            IO.Printer.Out.WriteLine(ans);
        }