Problem: 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.

Submission attempts (in order):
N = int(input())
A = sorted((map(int,input().split())))
A_Max = A[-1]
B = [True]*A_Max

for i in range(N):
    if B[A[i]]:
        for j in range(0, A_Max):
            if j < 2:
                continue
            elif A[i]*j > A_Max:
                break
            B[A[i] * j] = False

ans = 0
for i in range(N):
    if B[A[i]]:
            B[A[i]] = False
            ans += 1

print(ans)



N = int(input())
A = sorted((map(int,input().split())))
A_Max = A[-1]
B = [True]*A_Max

for i in range(N):
    if B[A[i]]:
        for j in range(2, A_Max):
            if A[i]*j > A_Max:
                break
            B[A[i] * j] = False

ans = 0
for i in range(N-1):
    if B[A[i]]:
        if A[i] == A[i+1]:
            B[A[i]] = False
        else:
            ans += 1

print(ans)



N = int(input())
A = sorted((map(int,input().split())))
A_Max = A[-1]
B = [True]*A_Max

for i in range(N):
    if B[A[i]]:
        for j in range(2, A_Max // A[i]+1):
            B[A[i]*j] = False

ans = 0
for i in range(N-1):
    if B[A[i]]:
        if A[i] == A[i+1]:
            B[A[i]] = False
        else:
            ans += 1

print(ans)



N = int(input())
A = sorted((map(int,input().split())))
A_Max = A[-1]
B = [True]*A_Max

for i in range(N):
    if B[A[i]]:
        for j in range(2, A_Max):
            if A[i]*j > A_Max:
                break
            B[A[i] * j] = False

ans = 0
for i in range(N-1):
    if B[A[i]]:
        if A[i] == A[i+1]:
            B[A[i]] = False
        else:
            ans += 1

print(ans)



N = int(input())
A = sorted((map(int,input().split())))
A_Max = A[-1]
B = [True]*A_Max+1

for i in range(N):
    if B[A[i]]:
        for j in range(2,A_Max):
            if A[i] * j > A_Max:
                break
            B[A[i] * j] = False

ans = 0
for i in range(N):
    if B[A[i]]:
            B[A[i]] = False
            ans += 1

print(ans)



N = int(input())
A = sorted((map(int,input().split())))
A_Max = A[-1]
B = [True]*A_Max

for i in range(N):
    if B[A[i]]:
        for j in range(2, A_Max):
            if A[i]*j > A_Max:
                break
            B[A[i] * j] = False

ans = 0
for i in range(N):
    if B[A[i]]:
            B[A[i]] = False
            ans += 1
        
print(ans)



N = int(input())
A = sorted((map(int,input().split())))
A_Max = A[-1]
B = [True]*A_Max

for i in range(N):
    if B[A[i]]:
        for j in range(2, A_Max//A[i]+1):
            B[A[i]*j] = False

ans = 0
for i in range(N-1):
    if B[A[i]]:
        if A[i] == A[i+1]:
            B[A[i]] = False
        else:
            ans += 1

print(ans)



N = int(input())
A = sorted((map(int,input().split())))
a_Max = A[-1]
B = [0]*a_Max
ans =0
for a in A:
    if B[a-1] == 0:
        B[a-1] = 1
        ans += 1
        for j in range(a*2-1,a_Max,a):
            B[j] = 2
    elif B[a-1] == 1:
        B[a-1] = 2
        ans -= 1
print(ans)


Verdicts: Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Runtime Error

Accepted