Problem:


Score : 500 points

Problem Statement

We have N integers. The i-th number is A_i.

\{A_i\} is said to be pairwise coprime when GCD(A_i,A_j)=1 holds for every pair (i, j) such that 1\leq i < j \leq N.

\{A_i\} is said to be setwise coprime when \{A_i\} is not pairwise coprime but GCD(A_1,\ldots,A_N)=1.

Determine if \{A_i\} is pairwise coprime, setwise coprime, or neither.

Here, GCD(\ldots) denotes greatest common divisor.

Constraints

2 \leq N \leq 10^6

1 \leq A_i\leq 10^6

Input

Input is given from Standard Input in the following format:

N
A_1 \ldots A_N

Output

If \{A_i\} is pairwise coprime, print pairwise coprime; if \{A_i\} is setwise coprime, print setwise coprime; if neither, print not coprime.

Sample Input 1

3
3 4 5

Sample Output 1

pairwise coprime

GCD(3,4)=GCD(3,5)=GCD(4,5)=1, so they are pairwise coprime.

Sample Input 2

3
6 10 15

Sample Output 2

setwise coprime

Since GCD(6,10)=2, they are not pairwise coprime. However, since GCD(6,10,15)=1, they are setwise coprime.

Sample Input 3

3
6 10 16

Sample Output 3

not coprime

GCD(6,10,16)=2, so they are neither pairwise coprime nor setwise coprime.



Sample input:
3
3 4 5


Sample output:
pairwise coprime

Submission status: Runtime Error

Solution code:
# compiled by pythran
"""
#pythran export main2()
import numpy as np
i4 = np.int32
i8 = np.int64


def get_primes(N):
    n_max = int(np.sqrt(N)) + 1
    p = np.zeros(N + 1, i8)
    p[0] = 1
    p[1] = 1
    for i in range(2, n_max):
        if p[i] == 0:
            j = i * 2
            while j <= N:
                p[j] = 1
                j += i
    return np.where(p == 0)[0]


def gcd(a, b):
    """Computes the greatest common divisor of integers a and b using
    Euclid's Algorithm.
    """
    while b != 0:
        a, b = b, a % b
    return a


def solve(A):
    g = A[0]
    for i in range(1, A.shape[0]):
        g = gcd(A[i], g)
    if g > 1:
        print('not coprime')
        return
    primes = get_primes(1000000)
    if len(A) > len(primes):
        print('setwise coprime')
        return
    for p in primes:
        count = 0
        for a in A:
            if a % p == 0:
                count += 1
        if count > 1:
            print('setwise coprime')
            return
    print('pairwise coprime')


def main(in_file):
    stdin = open(in_file)
    stdin.readline()
    A = np.array([int(x) for x in stdin.readline().split()])
    solve(A)

def main2():
    main('/dev/stdin')
"""
import os, sys
p = os.path.dirname(__file__)
pymain = os.path.join(p, "a.out")
if len(sys.argv) == 1:
    import subprocess
    if p == "":
        pymain = "./" + pymain
    subprocess.call(pymain)
else:
    import gzip, base64, stat
    gz = b'H4sIAP0kUl8C/+19C3xTVbb3SdJHeDWhIlRACBiwBSkN5dEWhJQSegIpVArIKBjSNqXRviY54eFjhGnrGEMR7zjq3Ot4mRk/h1HvHa7j53UchSLQotdRHqIgKA95pEQEZeShQu5ae++T7nOSQGH47vf7fr8vSnfW/+y99tprr7324+zs/ajNMV2r0QjyRytMFpAyDbAS2srwvKZoFMDyhG7wd7AwSEgBOomLZxWsivACYy2HehZPx9LlaRl/rVURDmTx5FDDhckC/7EqwrfvFRQhlCSaDmXNXEjRzIWLFeFzjOmGFGU6LUsXWkTR0KLFilDQCopQLl8S+zeX4XNZueRwGos3jYuPn9JjUiX5Pp8B862K8HkGP69KdxekSxG6/jGycA7LL5Fe9uoERSjXw+gaT/n4saNrKkfVeOr8y0ctzxs/avzYbF999hgik5HFLZ41L1rfWk7mPgzD5zu/WlDw0vYHNry27+xdr5zQ/Vao+DAXn41haVLhX1OacXHPrG5aTLmyp6DBZ+PhXwH8e/mpSe8+X/HOtu6r1jr/fCB3zx3fOO/7uGxd4+PNFX0f+NXro14Y2PBmn+d6Fi23P/BGlm2P40p6CYES0+PgK4T4uDcpPv4nbXz85tT4eI4mPp6eABcTyPl8AvzrBHhaAnnWJIifkRwfP5YAz0rAf32Ccg1MEL9Hgvg5CeL/Z4J6mZ4gvj0B/39PUO+2BPV7JIHeFiXI9yZdfHxCgvg/JuD/bAL5VyeQ82KC+FMSyJOVQJ+6BHLuTpCvPkH8ZxPYzzsJ8p2cgM+qBPJ/lKAeeybI970Eev4+QfzaBPnOTCCnMdrDKD8jE/DZCfgQ4WZhO/PLctpmg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0a1X6U9tPqyq9vO8n5x723k5z5fx3CfS+U51q32rmwvjl1avCL+irpmh6eT9A3sL48qrTn2Tyy+nl9/dWln69Sn61PzvPtS1+H2dokbKhpqjyNXIOgc9f3scVcnat/Mmq9NH9DSzYoLly+jRVevk95wbXlfOXP/hbCz2XXn6P2crSZ1xFf7ew/HPUdsXSl3Zh/3S8PfjGcva+ml2mi/u1ZsfxP90E5b3D8ue5BrZfKP3K/rt3gvSGRvb+VXPl9P8N0JAFi/iLAAA='
    bin = gzip.decompress(base64.b64decode(gz))
    with open(pymain, "wb") as f:
        f.write(bin)
    os.chmod(pymain, 0o775)

Submission status: Runtime Error

Solution code:
# region header
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
import copy
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7
# endregion
# region input function


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])

# endregion


class osa_k():
    def __init__(self, n):
        """高速素因数分解

        Args:
            n (int): n以下全ての値について素因数分解できるようにする
        """
        self.n = n
        self.minFactor = list(range(0, n + 1))
        self.prime = []

    def factorize(self, i):
        if not self.prime:
            self.get_sieve_of_eratosthenes()
        factor = []
        while i != 1:
            p = self.minFactor[i]
            factor.append(p)
            i //= p
        return factor

    def get_sieve_of_eratosthenes(self):
        """エラトステネスの篩
        """
        limit = math.sqrt(self.n)
        for prime in range(2, self.n + 1):
            if prime >= limit:
                break
            if self.minFactor[prime] == prime:
                self.prime.append(prime)
                for composite in range(2 * prime, self.n + 1, prime):
                    if self.minFactor[composite] == composite:
                        self.minFactor[composite] = prime


n = inp()
a = inpl()
factorizer = osa_k(10**6)
tmp = collections.defaultdict(int)
for i in a:
    p = set(factorizer.factorize(i))
    for j in p:
        tmp[j] += 1
if not tmp.values():
    print("pairwise coprime")
max_val = max(tmp.values())
if max_val == 1:
    print("pairwise coprime")
elif max_val == n:
    print("not coprime")
else:
    print("setwise coprime")

Submission status: Runtime Error

Solution code:
# region header
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
import copy
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7
# endregion
# region input function


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])

# endregion


class osa_k():
    def __init__(self, n):
        """高速素因数分解

        Args:
            n (int): n以下全ての値について素因数分解できるようにする
        """
        self.n = n
        self.minFactor = list(range(0, n + 1))
        self.prime = []

    def factorize(self, i):
        if not self.prime:
            self.get_sieve_of_eratosthenes()
        factor = []
        while i != 1:
            p = self.minFactor[i]
            factor.append(p)
            i //= p
        return factor

    def get_sieve_of_eratosthenes(self):
        """エラトステネスの篩
        """
        limit = math.sqrt(self.n)
        for prime in range(2, self.n + 1):
            if prime >= limit:
                break
            if self.minFactor[prime] == prime:
                self.prime.append(prime)
                for composite in range(2 * prime, self.n + 1, prime):
                    if self.minFactor[composite] == composite:
                        self.minFactor[composite] = prime


n = inp()
a = inpl()
factorizer = osa_k(10**6)
tmp = collections.defaultdict(int)
for i in a:
    p = set(factorizer.factorize(i))
    for j in p:
        tmp[j] += 1
max_val = max(tmp.values())
if max_val == 1:
    print("pairwise coprime")
elif max_val == n:
    print("not coprime")
else:
    print("setwise coprime")

Submission status: Runtime Error

Solution code:
#E_Coprime
import math
import functools

# エラトステネスの篩
        
def primes(n):
    is_prime = [1] * (n + 1)
    is_prime[0] = 0
    is_prime[1] = 0
    D_prime = [i for i in range(n+1)] 
    D_prime[0] = 0
    D_prime[1] = 1
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            D_prime[i] = i
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = 0
            D_prime[j] = i
    return D_prime

    

Fnum_list2 = []
# 入力
N = int(input())
A = list(map(int,input().split()))

#Fnum_list = eratosthenes(N)

A.sort()
Amax = A[-1]
Fnum_list2 = primes(Amax)

ans = 1
#Fnum_list = eratosthenes(N)
Ai_primes     = set()
Ai_primes_add = []
gcd_num = 0
for i in range(len(A) -1 ):
    p = A[i]
    while p != 1:
        j = p
        p = int (p / Fnum_list2[j])
        if Fnum_list2[j] in Ai_primes:
            ans = 0
        else:
            Ai_primes_add.append(Fnum_list2[j])
    if Fnum_list2[j] in Ai_primes:
        break
    else:
        Ai_primes |= set(Ai_primes_add)
        Ai_primes_add.clear()

gcd_num = functools.reduce(math.gcd,A)

if ans == 0:
    if gcd_num == 1:
        ans = 2

# 出力
if ans == 1:
    print("pairwise coprime")
else:
    if ans == 2:
        print("setwise coprime")
    else:
        print("not coprime")

Submission status: Runtime Error

Solution code:
import sys
from collections import defaultdict as dd
from collections import deque
from functools import *
from fractions import Fraction as f
from copy import *
from bisect import *	
from heapq import *
from math import *
from itertools import permutations ,product
 
def eprint(*args):
    print(*args, file=sys.stderr)
zz=1
 
#sys.setrecursionlimit(10**6)
if zz:
	input=sys.stdin.readline
else:	
	sys.stdin=open('input.txt', 'r')
	sys.stdout=open('all.txt','w')
def inc(d,c):
	d[c]=d[c]+1 if c in d else 1
def bo(i):
	return ord(i)-ord('A')	
def li():
	return [int(xx) for xx in input().split()]
def fli():
	return [float(x) for x in input().split()]	
def comp(a,b):
	if(a>b):
		return 2
	return 2 if a==b else 0		
def gi():	
	return [xx for xx in input().split()]
def fi():
	return int(input())
def pro(a): 
	return reduce(lambda a,b:a*b,a)		
def swap(a,i,j): 
	a[i],a[j]=a[j],a[i]	
def si():
	return list(input().rstrip())	
def mi():
	return 	map(int,input().split())			
def gh():
	sys.stdout.flush()
def isvalid(i,j):
	return 0<=i<n and 0<=j<n	
def bo(i):
	return ord(i)-ord('a')	
def graph(n,m):
	for i in range(m):
		x,y=mi()
		a[x].append(y)
		a[y].append(x)


t=1
N=10**4
spf=[i for i in range(N+1)]
for i in range(2,int(ceil(sqrt(N)))+2):
	if spf[i]==i:
		for j in range(i*i,N,i):
			if spf[j]==j:
				spf[j]=i
			
def fact(i):
	s=set()
	while i!=1:
		s.add(spf[i])	
		i//=spf[i]
	return s	

while t>0:
	t-=1
	n=fi()
	a=li()
	s=set()
	g=a[0]
	flag=0
	for i in range(n):
		g=gcd(g,a[i])
		k=fact(a[i])
		if len(s&k)!=0:
			flag|=1
		s|=k
	if flag==0:
		print("pairwise coprime")
	elif g==1:
		print("setwise coprime")	
	else:
		print("not coprime")

Submission status: Runtime Error

Solution code:
import math
n = int(input())
a = list(map(int,input().split()))

def generate_D(maxA):
  seq = [i for i in range(maxA+1)]
  p = 2
  while p*p <= maxA:
    if seq[p]==p:
      for q in range(p*2,maxA+1,p):
        if seq[q]==q:
          seq[q] = p
    p += 1
    return seq

cur = a[0]
for v in a[1:]:
  cur = math.gcd(cur,v)
if cur > 1:
  print('not coprime')
else:  
  d = generate_D(max(a))
  primes = set([])
  tf = 1
  for v in a:
    tmp = set([])
    while v > 1:
      tmp.add(d[v])
      v //= d[v]
    for k in tmp:
      if k in primes:
        tf = 0
      else:
        primes.add(k)
  if tf:
    print('pairwise coprime')
  else:
    print('setwise coprime')

Submission status: Runtime Error

Solution code:
import math
n = int(input())
a = list(map(int,input().split()))

def generate_D(maxA):
  seq = [i for i in range(maxA+1)]
  p = 2
  while p*p <= maxA:
    if seq[p]==p:
      for q in range(p*2,maxA+1,p):
        if seq[q]==q:
          seq[q] = p
    p += 1
    return seq

cur = a[0]
for v in a[1:]:
  cur = math.gcd(cur,v)
if cur > 1:
  print('not coprime')
else:  
  d = generate_D(max(a))
  primes = set([])
  for v in a:
    tmp = set([])
    while v > 1:
      tmp.add(d[v])
      v //= d[v]
    for k in tmp:
      if k in primes:
        tf = 0
        print('setwise coprime')
        exit()
      else:
        primes.add(k)
  else:
    print('pairwise coprime')

Submission status: Runtime Error

Solution code:
n = int(input())
a = list(map(int, input().split()))
maxn = 10 ** 6 + 1
numl = [0] * maxn
flag = 0
for i in a:
    for j in range(2, maxn):
        if(j*j > i):
            if(numl[i] == 0):
                numl[i]+=1
            else:
                flag = 1
            break
        if(i % j == 0):
            if(numl[j] == 0):
                numl[j]+=1
            else:
                flag = 1
                break
    if(flag == 1):
        ans = a[0]
        for k in range(1, n):
            ans = gcd(ans, a[k])
        if(ans == 1):
            print("setwise coprime")
        else:
            print("not coprime")
        break
else:
    print("pairwise coprime")

Submission status: Runtime Error

Solution code:
import sys, io, os, re
from bisect import bisect, bisect_left, bisect_right, insort, insort_left, insort_right
from pprint import pprint
from math import sin, cos, pi, radians, sqrt, floor, ceil
from copy import copy, deepcopy
from collections import deque, defaultdict
from fractions import gcd
from functools import reduce
from itertools import groupby, combinations
from heapq import heapify, heappush, heappop

# sys.setrecursionlimit(5000)

n1 = lambda: int(sys.stdin.readline().strip())
nn = lambda: list(map(int, sys.stdin.readline().strip().split()))
f1 = lambda: float(sys.stdin.readline().strip())
fn = lambda: list(map(float, sys.stdin.readline().strip().split()))
s1 = lambda: sys.stdin.readline().strip()
sn = lambda: list(sys.stdin.readline().strip().split())
nl = lambda n: [n1() for _ in range(n)]
fl = lambda n: [f1() for _ in range(n)]
sl = lambda n: [s1() for _ in range(n)]
nm = lambda n: [nn() for _ in range(n)]
fm = lambda n: [fn() for _ in range(n)]
sm = lambda n: [sn() for _ in range(n)]

def array1(n, d=0): return [d] * n
def array2(n, m, d=0): return [[d] * m for x in range(n)]
def array3(n, m, l, d=0): return [[[d] * l for y in xrange(m)] for x in xrange(n)]
def linc(A, d=1): return list(map(lambda x: x + d, A))
def ldec(A, d=1): return list(map(lambda x: x - d, A))

N = n1()
A = nn()

if max(A) == 1:
    print("pairwise coprime")
    exit(1)

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1)) + 1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr.append([i, cnt])

    if temp != 1: arr.append([temp, 1])
    if arr == []: arr.append([n, 1])
    return arr

dic = defaultdict(list)

for ai in A:
    fact = factorization(ai)
    for i in range(len(fact)):
        dic[fact[i][0]].append(ai)

#print(dic)

maxlen = 0
for k, v in dic.items():
    maxlen = max(len(v), maxlen)

print(dic)

if maxlen == 1:
    print("pairwise coprime")
elif maxlen == N:
    print("not coprime")
else:
    print("setwise coprime")