Problem:


Score : 400 points

Problem Statement

Given is a number sequence A of length N.

Find the number of integers i \left(1 \leq i \leq N\right) with the following property:

For every integer j \left(1 \leq j \leq N\right) such that i \neq j , A_j does not divide A_i.

Constraints

All values in input are integers.

1 \leq N \leq 2 \times 10^5

1 \leq A_i \leq 10^6

Input

Input is given from Standard Input in the following format:

N
A_1 A_2 \cdots A_N

Output

Print the answer.

Sample Input 1

5
24 11 8 3 16

Sample Output 1

3

The integers with the property are 2, 3, and 4.

Sample Input 2

4
5 5 5 5

Sample Output 2

0

Note that there can be multiple equal numbers.

Sample Input 3

10
33 18 45 28 8 19 89 86 2 4

Sample Output 3

5



Sample input:
5
24 11 8 3 16


Sample output:
3

Submission status: Wrong Answer

Solution code:
def examA():
    X = LI()
    for i in range(len(X)):
        if X[i]==0:
            ans = i+1
    print(ans)
    return

def examB():
    X, Y = LI()
    ans = "No"
    for i in range(X+1):
        if i*2+(X-i)*4==Y:
            ans = "Yes"
    print(ans)
    return

def examC():
    X, N = LI()
    P = LI()
    P = set(P)
    cur = inf
    ans = -1
    for i in range(-1,102):
        if i in P:
            continue
        now = abs(i-X)
        if now<cur:
            ans = i
            cur = now
    print(ans)
    return

def examD():
    N = I()
    A = LI()
    C = set()
    n = 10**6+1
    D = set()
    for a in A:
        if a in D:
            C.discard(a)
            continue
        D.add(a)
        C.add(a)
    if 1 in D:
        print(0)
        return
    C2 = deepcopy(C)
    for a in C:
        for i in range(2,1+n//a):
            if (i*a) in C2:
                C2.discard(i*a)
    ans = len(C2)
    print(ans)
    return

def examE():
    N, Q = LI()
    AB = [LI()for _ in range(N)]



    ans = 0
    print(ans)
    return

def examF():
    H, W, K = LI()
    x1,y1,x2,y2 = LI()
    x1 -= 1; y1 -= 1; x2 -= 1; y2 -= 1
    C = [SI()for _ in range(H)]

    def bfs_grid(h, w, s, maze):
        distance = [[inf] * w for _ in range(h)]

        def bfsg():
            queue_up = deque()
            queue_d = deque()
            queue_r = deque()
            queue_l = deque()
            queue_up.append(s)
            queue_d.append(s)
            queue_r.append(s)
            queue_l.append(s)
            distance[s[0]][s[1]] = 0
            while (len(queue_up) or len(queue_r) or len(queue_d) or len(queue_l)):
                if queue_up:
                    y, x = queue_up.popleft()
                    for k in range(1, K + 1):
                        nx, ny = x, y + k
                        if (0 <= nx < w and 0 <= ny < h and maze[ny][nx] != '@'):
                            if distance[ny][nx] <= distance[y][x] + 1:
                                continue
                            queue_r.append((ny, nx))
                            queue_l.append((ny, nx))
                            distance[ny][nx] = distance[y][x] + 1
                        else:
                            break
                        if k == K:
                            queue_up.append((ny, nx))
                if queue_d:
                    y, x = queue_d.popleft()
                    for k in range(1, K + 1):
                        nx, ny = x, y - k
                        if (0 <= nx < w and 0 <= ny < h and maze[ny][nx] != '@'):
                            if distance[ny][nx] <= distance[y][x] + 1:
                                continue
                            queue_r.append((ny, nx))
                            queue_l.append((ny, nx))
                            distance[ny][nx] = distance[y][x] + 1
                        else:
                            break
                        if k == K:
                            queue_d.append((ny, nx))
                if queue_r:
                    y, x = queue_r.popleft()
                    for k in range(1, K + 1):
                        nx, ny = x + k, y
                        if (0 <= nx < w and 0 <= ny < h and maze[ny][nx] != '@'):
                            if distance[ny][nx] <= distance[y][x] + 1:
                                continue
                            queue_up.append((ny, nx))
                            queue_d.append((ny, nx))
                            distance[ny][nx] = distance[y][x] + 1
                        else:
                            break
                        if k == K:
                            queue_r.append((ny, nx))
                if queue_l:
                    y, x = queue_l.popleft()
                    for k in range(1, K + 1):
                        nx, ny = x - k, y
                        if (0 <= nx < w and 0 <= ny < h and maze[ny][nx] != '@'):
                            if distance[ny][nx] <= distance[y][x] + 1:
                                continue
                            queue_up.append((ny, nx))
                            queue_d.append((ny, nx))
                            distance[ny][nx] = distance[y][x] + 1
                        else:
                            break
                        if k == K:
                            queue_l.append((ny, nx))

            return distance

        return bfsg()
    L = bfs_grid(H,W,(x1,y1),C)
    #print(L)
    ans = L[x2][y2]
    if ans==inf:
        ans = -1
    print(ans)
    return

from decimal import Decimal as dec
import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
def I(): return int(input())
def LI(): return list(map(int,sys.stdin.readline().split()))
def DI(): return dec(input())
def LDI(): return list(map(dec,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**7)

if __name__ == '__main__':
    examD()

"""
142
12 9 1445 0 1
asd dfg hj o o
aidn
"""

Submission status: Wrong Answer

Solution code:
import sys
import numpy as np

N = int(input())
A = np.array([int(x) for x in input().split()])
if(sum(A%A[0])==0):
  print(0)
  sys.exit()
n = 0
for i in range(N):
  x = A[i]
  a = x % A[A!=x]
  if(np.sort(a)[0] != 0):
    n += 1
print(n)

Submission status: Wrong Answer

Solution code:
from collections import deque
import collections
n = int(input())
a = list(map(int,input().split()))
a.sort()
# print(a)
a = deque(a)

# b = a[-1]
# print(b)
# c = 0
x = set()
while a[0]!=max(a) :
    p = a.popleft()
    # x = set()
    for i in a:
        if not i in x:
            # print(i,p)
            if i%p==0 and i!=p:
                # print(i)
                x.add(i)
                # print(x)
    # for j in x:
    #      a.remove(j) 
    a.append(p)
# print(x)
for j in x:
    a.remove(j)
# print(a)
y=len(a)
# print(a)
c = (collections.Counter(a)).values()
# print(c)
for i in c:
    # print(i)
    if i!=1:
        y-=i
    # c+=1
    # if a[i]<b/2:
    #     a =a[:i+1]+ [k for k in a if k%a[i]!=0]
print(y)

Submission status: Wrong Answer

Solution code:
N = input()
a_list = list(map(int,input().split()))
count = 0
for i in range(len(a_list)):
    for j in range(len(a_list)):
        if i == j:
            continue
        elif a_list[i] % a_list[j] == 0:
            break
        elif j == len(a_list)-1:
            count += 1
print(count)

Submission status: Wrong Answer

Solution code:
n=int(input())
a=list(map(int,input().split()))
a.sort(reverse=True)
ans=1
for i in range(n-1):
    flg=True
    for j in range(n-1,i,-1):
        if a[i]%a[j]==0:
            flg=False
            break
    if flg:
        ans+=1
if n>1:
    if a[-1]==a[-2]:
        ans-=1
print(ans)

Submission status: Wrong Answer

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

a.sort()

import collections
c = collections.Counter(a)

d=[]
for ck,cv in c.items():
    if cv>=2:
       d.append(ck) 
dset=set(d)
    
aa=[]

icnt=0
while True:
    aa.append(a[0])
    a2=[]
    for i in range(1,len(a)):
        if a[i]%a[0]!=0:
            a2.append(a[i])
    a=a2.copy()
#    print(aa,a)     
    if len(a2)==0:
        break
    icnt+=1
    if icnt>10:break

aaset=set(aa)
aaset=aaset-dset    
print(len(aaset))

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))

cnt = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        if A[i] % A[j] == 0:
            break
        elif j == N - 1:
            cnt += 1
            # print(A[i], A[j])

print(cnt)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int, input().split()))
ans = 0
flag = True
for i in a:
  for j in a:
    if(i != j):
      if(i % j == 0):
        flag = False
  if(flag):
    ans = ans +1
  flag = True
print(ans)

Submission status: Wrong Answer

Solution code:
# /usr/bin/python3
# -*- coding: utf-8 -*-
from queue import Queue
from queue import LifoQueue as Stack
from math import sqrt, floor, ceil, log2, log10, pi
from fractions import gcd
from itertools import permutations, combinations
from operator import itemgetter
from functools import cmp_to_key

# from numpy import gcd


INF=1001001001
__MOD__=(10**9)+7
yn = 'YNeos'
judge = False
cnt = 0
ans = None


def lcm(a, b):
    return (a*b) // gcd(a,b)

def intinput():
    return int(input())

def mulinputs():
    return map(int,input().split())

def lineinputs(func=intinput):
    datas = []
    while True:
        try:
            datas.append(func())
        except EOFError:
            break
    return datas

class ModInt():
    def __init__(self, x):
        self.__x = (x % __MOD__)
    def __add__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x + other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x + other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __radd__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x + self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x + self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __sub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x - other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x - other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rsub__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x - self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x - self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __mul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rmul__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x * self.__x)%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x * self.__x)%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __truediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((self.__x * other.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((self.__x * other.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")
    def __rtruediv__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__((other.__x * self.__modinv())%__MOD__))
        elif type(other) == ModInt:
            return self.__class__((other.__x * self.__modinv())%__MOD__)
        else:
            raise Exception("Not Int or Not ModInt")

    def __pow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(self.__x, other.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(self.__x, other.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")
    def __rpow__(self, other):
        if type(other) == int:
            other = self.__class__(other)
            return int(self.__class__(pow(other.__x, self.__x, __MOD__)))
        elif type(other) == ModInt:
            return self.__class__(pow(other.__x, self.__x, __MOD__))
        else:
            raise Exception("Not Int or Not ModInt")

    def __modinv(self, m=__MOD__):
        a = self.__x
        if a == 0:
            raise ZeroDivisionError()
        if gcd(a, m) != 1:
            raise Exception("%sの逆数は求まりません。" % a)
        b, u, v = m, 1, 0
        while b != 0:
            t = a//b;
            a -= t*b
            a, b = b, a
            u -= t * v
            u, v = v, u
        u %= m
        if u < 0:
            u += m
        return u
    def __int__(self):
        return self.__x
    def __str__(self):
        return str(self.__x)



if __name__ == '__main__':
    N = intinput()
    datas = list(mulinputs())


    # 出力
    # cnt = 0
    # for i in range(N):
    #     is_break = False
    #     for j in range(N):
    #         if i==j:
    #             continue
    #         if datas[i] % datas[j] == 0:
    #             is_break = True
    #             break
    #     if is_break:
    #         continue
    #     cnt += 1
# 
    # print(cnt)


    datas.sort()
    p = []
    tmp = datas[0]
    if len([ d for d in datas if d % tmp != 0]) == 0:
        print(0)
        exit()
    while datas:
        tmp = datas.pop(0)
        if len(datas) == 0:
            p.append(tmp)
            break
        datas = [ d for d in datas if d % tmp != 0]
        # if len(datas) == 0:
        #     print(len(p))
        #     exit()
        p.append(tmp)
    print(len(p))

Submission status: Wrong Answer

Solution code:
def main():
    N = int(input())
    A = list(map(int, input().split()))

    A.sort()
    ans = 0
    temp = 0
    if N == 1:
        return 1

    if A[0] == 1:
        return 1
            
    for i in range(N):
        if i == 0 and A[i+1] != A[i]:
            ans += 1
            continue

        temp = A[i]

        if i == N-1 and temp == A[i-1]:
            continue
        elif i != N-1:
            if temp == A[i+1] or temp == A[i-1]:
                continue

        for j in range(N):
            if A[j] <= temp/2 and A[i]%A[j] == 0:
                break
            elif A[j] <= temp//2 and A[i]%A[j] != 0:
                continue
            elif A[j] > temp//2:
                ans += 1
                break
    return ans

print(main())

Submission status: Wrong Answer

Solution code:
import numpy as np

if __name__ == '__main__':
    n = int(input().strip())
    a = np.array(input().strip().split()).astype(int)
    bool_mat = []
    ans = 0

    print(a)
    for i in a:
        bool_mat.append(a % i == np.zeros(n))

    np.sum(bool_mat)
    for i in np.sum(bool_mat, axis=0):
        if i == 1:
            ans += 1
    print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
x = 0

a.sort()

for i in range(n):
    flag=True
    for j in range(n):
        if(((a[i]%a[j]) == 0) and (a[i] != a[j])):
            flag=False
    if((flag != True) and (a[i] != a[j])):
        x += 1

print(x)

Submission status: Wrong Answer

Solution code:
import sys
sys.setrecursionlimit(4100000)
import math
INF = 10**9
import fractions

def main():
    n = int(input())
    A = list(map(int, input().split()))

    if len(set(A)) != len(A):
        print(0)
        return

    A.sort()
    ans = len(A)
    for i in range(n):
        for j in range(n):
            r = A[-i-1]
            l = A[j]
            if n+(-i-1) == j:
                break
            if r % l == 0:
                ans -= 1
                break
            if l >= r**(1/2):
                break
    print(ans)









if __name__ == '__main__':
    main()

Submission status: Wrong Answer

Solution code:


def main():
    n = int(input())
    a = list(map(int, input().split()))
    cnt = [0]*n
    a.sort(reverse=True)

    for i in range(n-1):
        if cnt[i] == 1:
            continue
        for j in range(i+1,n):
            if a[i] == a[j]:
                cnt[i] = 1
                cnt[j] = 1
                break
            if a[i]%a[j] == 0:
                cnt[i] = 1
                break
    print(n - sum(cnt))

if __name__ == "__main__":
    main()

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))
import sys
A.sort()
if 1 in A:
    if A.count(1) == N:
        print(0)
    else:
        print(1)
    sys.exit()

num_list = []
for i in range(N):
    tmp_list = [A[i]*j for j in range(1,10**5+1) if A[i]*j <= max(A)]
    inter = list(set(A) & set(tmp_list))
    num_list += inter

from collections import Counter
c = Counter(num_list)
keys, values = zip(*c.most_common())
print(values.count(1))

Submission status: Wrong Answer

Solution code:
def resolve():
    import bisect
    import math
    n = int(input())
    a = list(map(int, input().split()))
    a1 = {}
    for i in range(len(a)):
        if a[i] in a1:
            a1[a[i]] += 1
        else:
            a1[a[i]] = 1

    a = sorted(list(a1.keys()))
    maxa = a[-1]
    maxi = bisect.bisect_left(a, math.ceil(maxa/a[0]))
    ans = [1]*(len(a))
    for i in range(0, maxi+1):
        if ans[i] == 1:
            for j in range(i+1, len(a)):
                if ans[j] == 0:
                    continue
                if a[j] == a[i]:
                    ans[i] = 0
                if a[j] % a[i] ==0:
                    ans[j] = 0
        if a1[a[i]] != 1:
            ans[i] = 0
    print(sum(ans))
resolve()

Submission status: Wrong Answer

Solution code:
from math import sqrt
from collections import Counter
 
def is_prime(n):
  if n == 1:
    return False
  for i in range(2, int(sqrt(n))+1):
    if n % i == 0:
      return False
  return True

a=int(input())
b=[int(x) for x in input().split()]
b=sorted(b)
d=Counter(b)
c=0
for i in range(0, a):
  if d[b[i]] > 1:
    c+=1
  elif not is_prime(b[i]):
    for j in range(0, i):
      if b[i] % b[j] == 0:
        c+=1
        break
print(a-c)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
a.sort()
count = 0
for m in a:
    if a.count(m) ==1:
        if m <= a[-1]//2:
            j=2
            while m * j <= a[-1]:
                if m * j in a:
                    a.remove(m*j)
                j += 1
    else:
        while m in a:
            a.remove(m)
print(len(a))

Submission status: Wrong Answer

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

a=sorted(a)
cnt=0
if n>1:
    for i in range(n):
        if i == 0:
            if a[i] == a[i+1]:
                cnt+=1
            continue
        for j in range(i):
            if i == j:
                continue
            elif a[i]<a[j]*2:
                break
            else:
                if (a[i]%a[j])==0:
                    cnt+=1
                    break
    ans=n-cnt
else:
    ans=0
print(ans)

Submission status: Wrong Answer

Solution code:
# coding: utf-8

############################

n = int(input())
a = list(map(int,input().split()))
ans=0

for i in a:
    for j in a:
        if i!=j and i%j==0:
            ans +=1
            break

print( n*(1+len(a)-len(list(set(a)))) - ans )

Submission status: Wrong Answer

Solution code:
from collections import Counter
N = int(input())
A = sorted([int(x) for x in input().split()])
if A[0] == 1:
    print(N)
    exit()
cA = Counter(A)

cand = []
ans = 0
for a, val in cA.items():
    if len(cand) != 0 and val == 1:
        for t in cand:
            if a % t == 0:
                break
        else:
            #print(a)
            cand.append(a)
            ans += val
    elif val == 1:
        #print(a)
        cand.append(a)
        ans += val
    else:
        continue
print(ans)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
A.sort(reverse=True)
count = 1
for i in range(N-1):
  flag = 1
  for j in range(N-1, i, -1):
    if A[i] % A[j] == 0:
      flag = 0
      break
  if flag:
      count += 1
if N == 1:
  print(0)
elif A[0] == A[1]:
  print(0)
else:
  print(count)

Submission status: Wrong Answer

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

a = sorted(set(a))
a.reverse()
print(a)
ans = 0

x = []
while a:
    x.append(a.pop())
    b = []
    print(a,x)
    for i in range(len(a)):
        for j in range(len(x)):
            if a[i] % x[j] != 0 and a[i] not in b:
                b.append(a[i])
    a = b
"""
for i in range(len(a)):
    for j in range(len(a)-1,-1,-1):
        #print(i,j)
        if i == j:
            continue
        #print(a[i],a[j])
        if a[i] % a[j] == 0:
            break
        if j == n - 1:
            ans += 1
"""
print(len(x))

Submission status: Wrong Answer

Solution code:
N = int(input())
a = list(map(int,input().split()))
A = sorted(a, reverse=True)
count = 0
for i in range(N-1):
  flag = False
  for j in range(i+1,N):
    if i != j:
      if A[i] % A[j] == 0:
        flag = True
        break
  if flag == False:
    count += 1
print(count)

Submission status: Wrong Answer

Solution code:
import numpy as np

N=int(input())
A=tuple(map(int,input().split()))

A_sorted=np.sort(A)

result=[]
while A_sorted.size>0:
    a=A_sorted[0]
    A_sorted=A_sorted[1:]
    if a in A_sorted:
        A_sorted=A_sorted[A_sorted!=a]
        continue
    result.append(a)
    A_sorted=A_sorted[A_sorted%a!=0]
print(len(result))

Submission status: Wrong Answer

Solution code:
import math
N=int(input())
A=list(map(int, input().split()))
A=sorted(A)
if max(A)==min(A):
    print(0)
    exit()




nums=[0]*(2*10**5)

ans=[]

for i in range(N):
    a=A[i]
    on=True
    if i==0:
        ans.append(a)
    for x in ans:
        if a%x==0:
            on=False
    if on:
        ans.append(a)


print(len(ans))

Submission status: Wrong Answer

Solution code:
import math

n = int(input())
aL = sorted(list(map(int, input().split(" "))))

ans = n
for i in range(n - 1, -1, -1):
    for j in range(i):
        if aL[j] * 2 > aL[i]:
            break
        if aL[i] % aL[j] == 0:
            ans -= 1
            break

d = set()
for a in aL:
    d.add(a)
if len(d) == 1 and n != 1:
    print(0)
    exit()

print(ans)

Submission status: Wrong Answer

Solution code:


n = int(input())
a = list(map(int, input().split()))

a.sort(reverse=True)
ans = 0

if a[n - 1] == 1:
    print("1")
else:
    for i in range(n - 1):
        if a[i] != a[i + 1]:
            for j in range(n):
                if a[i] % a[n - j - 1] == 0 and i != n - j - 1:
                    break
                if n-j-1 ==  i:
                    ans += 1
    if a.count(a[n - 1]) < 2:
        ans += 1
    print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict
n = int(input())
a = list(map(int,input().split()))
count = defaultdict(int)
for i in a:
    count[i] += 1
a.sort()
ans = 0
div = set()
for i in range(n):
    if count[a[i]]==1:
        fl = 0
        for j in div:
            if a[i]%j==0:
                fl = 1
                break
        if fl==0:
            div.add(a[i])
            ans+=1
print(ans)

Submission status: Wrong Answer

Solution code:
import collections
N = int(input())
A = list(map(int,input().split()))
c = collections.Counter(A)

w = []
cnt = 0

lc = list(c.keys())
lc.sort()
for i in lc:
  if c[i] != 1:
    continue
  else:
    res = 0
    for j in w:
      if j > i//2 + 1:
        break
      if i%j == 0:
        res = 1
        break
    if res == 0:    
      w.append(i)
      cnt += 1
if N == 1:
  print(0)
else:  
  print(cnt)

Submission status: Wrong Answer

Solution code:
def solve():
    n=int(input())
    a=list(map(int,input().split()))
    ans=0
    a2=set(a)
    a2=list(sorted(a2))
    if a2[0]==1:
        if a.count(1)==1:
            ans=1
        else:
            ans=0
    else:
        def c1(num1):
            return a.count(num1)
        for i in range(len(a2)):
            num=0
            if c1(a2[i])==1:
                for j in range(i):
                    if a2[i]%a2[j]==0:
                        num=1
                        break
                    if a2[i]/2+1<a2[j]:
                        break
                if num==0:
                    ans+=1
        print(ans)

solve()

Submission status: Wrong Answer

Solution code:
n=int(input())
A=list(map(int,input().split()))
count=n
A.sort(reverse=True)
for i in range(n):
    for j in range(i+1,n):
        if A[i]%A[j]==0:
            count-=1
            break
print(count)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int,input().split()))

A.sort()
counter_ = 0
i = 0
div = []
judge = True
for i in range(N):
    for div_ in div:
        if A[i] % div_ == 0:
            counter_ += 1
            judge = False
            break
        if A[i] <= div_ * 2:
            break
    if judge:
        div.append(A[i])

for div_ in div:
    if A.count(div_) > 1:
        counter_ += 1
        
print(N - counter_)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))
A = sorted(A)
res = 0
for i in range(N):
    if i + 1 < N:
        if A[i] == A[i+1]:
            continue
    a = A[i]
    sra = int(a ** 0.5) + 1
    for j in range(0, i):
        b = A[j]
        if a % b == 0:
            break
        if b > sra:
            res += 1
            break
    else:
        res += 1
print(res)

Submission status: Wrong Answer

Solution code:
import numpy as np
N = list(map(int, input().split()))[0]
A = np.array(list(((map(int, input().split())))))
idx = np.argsort(A)
A = np.sort(A)
print(A)
Z = np.zeros(N)

def get_result():
    result = 0
    for i in range(N):
        flag = True
        if i < N - 1 and A[i] == A[i + 1]:
            flag = False
        for j in range(i):
            if Z[j] == 0 and A[i] % A[j] == 0:
                flag = False
                Z[i] = 1
                print(Z)
                break
            if A[i] / A[j] < 2:
                break
        if flag:
            result += 1
    return result

print(get_result())

Submission status: Wrong Answer

Solution code:
N = int(input())
A = sorted([int(i) for i in input().split()],reverse=True)
c = 0

for i in range(N-1):
  b = A[i]
  for y in range(i+1,N):
    if b % A[y] == 0:
      break
  else:
    c += 1
else:
  if A[N-2] > A[N-1]:
    c += 1
  print(c)

Submission status: Wrong Answer

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

s = 0
u = -1
for i in a:
    #print('s='+str(s))
    #print('i='+ str(i))
    t = 0
    for j in a:
        #print('j='+ str(j))
        if j != i and i % j == 0:
            t += 1
    if j != i and t == 0:
        s += 1
print(s)

Submission status: Wrong Answer

Solution code:
N = int(input())
A = list(map(int, input().split()))

ans = 0
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        if A[i] % A[j] == 0:
            break
        if j == N - 1:
            ans += 1

print(ans)

Submission status: Wrong Answer

Solution code:
from collections import defaultdict

n = int(input())
As  = list(map(int, input().split()))
if n == 1:
    print(0)
    exit()

Ss = sorted(As)
primes = set()
cnt = 0
d = defaultdict(int)
As = [False] * (10**6+10)
for s in Ss:
    d[s] += 1

for s in Ss:
    if As[s]:continue
    else:
        if d[s] == 1:
            cnt += 1
        ind = 1
        while s * ind <= 10**6:
            As[s*ind] = True
            ind += 1
print(cnt)

Submission status: Wrong Answer

Solution code:
X,=map(int, input().split())
A=list(map(int, input().split()))
A.sort()
ex=0
for i in range(X):
  for j in range(i):
    if(A[i]%A[j]==0):
      ex+=1
      break
print(X-ex)

Submission status: Wrong Answer

Solution code:
N = int(input())
AList = list(map(int, input().split()))
if AList.count(AList[0]) == N:
  print(0)
  exit()
minNum = min(AList)
ansList = [minNum]
AList.remove(minNum)
ansCount = 1
while AList:
  minNum = min(AList)
  ansLen = len(ansList)
  for i in range(ansLen):
    if minNum % ansList[i] == 0 :
      AList.remove(minNum)
      break
    if i+1 == ansLen:
      ansList.append(minNum) 
      AList.remove(minNum)
      ansCount += 1
  
print(ansCount)

Submission status: Wrong Answer

Solution code:
n = int(input())
a = list(map(int,input().split()))
spl = [[] for i in range(n)]
ans = 0
check = [0] * n

for i in range(n):
    for j in range(1, int(a[i]**0.5) + 1):
        if a[i] % j == 0:
            spl[i].append(j)
            if  j != a[i] // j and j != 1:
                spl[i].append(a[i] // j)
for i in range(n):
    if any(spl[i][j] in a for j in range(len(spl[i]))):
        pass
    else:
        ans += 1
        check[i] = 1
for i in range(n):
    list = a
    if check[i] == 1 and a.count(a[i]) > 1:
        ans -= 1
print(ans)

Submission status: Wrong Answer

Solution code:
n = int(input())
A = sorted(map(int, input().split()))

B = [1 for _ in range(n)]
for i in range(n):
  if A[i]*2 > A[n-1] and A[i] <= A[n-1]:
    if i < n-1 and A[i] == A[i+1]:
      B[i] = 0
      B[i+1] = 0
      for j in range(n)[i+2:]:
        if A[j] == A[i]:
          B[j] = 0
        else:
          break
    else:
      break
      
  c = 0
  if B[i] == 0:
    continue
  if i < n-1 and A[i] == A[i+1]:
    B[i] = 0
    B[i+1] = 0
    for j in range(n)[i+2:]:
      if A[j] == A[i]:
        B[j] = 0
      else:
        break
  while(A[i]*c <= A[n-1]):
    c += 1
    for j in range(n)[i+1:]:
      if A[j] == A[i]*c:
        B[j] = 0
print(sum(B))

Submission status: Wrong Answer

Solution code:
N = int(input())
nums = list(map(int, input().split()))
count = [0]*N
nums.sort()
for i in range(N):
  fNum = nums[i]
  for j in range(0,N):
    if (nums[j] > fNum):
      break
    if (count[i] == 1):
      break
    if (i == j):
      continue
    else:
      sNum = nums[j]
      if (fNum%sNum == 0):
      	count[i] += 1
answer = 0
print(count)
for i in count:
  if (i == 0):
    answer += 1
print(answer)

Submission status: Wrong Answer

Solution code:
n = int(input())
arg = list(map(int, input().split()))

ans = 0
for i in range(n):
    numi = arg[i]
    for j in range(n):
        if i == j:
            continue
        else:
            numj = arg[j]
            if numi < numj * 2:
                continue
            num = numi % numj
            if num == 0:
                ans += 1
                break

if ans == 0:
    print(ans)
else:
    print(n - ans)