Ejemplo n.º 1
0
    static object Solve()
    {
        var n = int.Parse(Console.ReadLine());
        var a = Read();

        var pf = new PrimeFactorization(1000000);
        var u  = new bool[1000000 + 1];

        if (IsPairwiseCoprime())
        {
            return("pairwise coprime");
        }
        if (a.Aggregate(Gcd) == 1)
        {
            return("setwise coprime");
        }
        return("not coprime");

        bool IsPairwiseCoprime()
        {
            foreach (var x in a)
            {
                foreach (var f in pf.GetFactorTypes(x))
                {
                    if (u[f])
                    {
                        return(false);
                    }
                    u[f] = true;
                }
            }
            return(true);
        }
    }