Problem p02642 (python)

Fixed submission:
N = int(input())
A = sorted((map(int,input().split())))
a_Max = A[-1]
B = [0]*a_Max

for a in A:
    if B[a-1] == 0:
        B[a-1] = 1
        for j in range(2,a_Max+1):
            if a*j > a_Max:
                break
            B[a*j-1] = 2
    elif B[a-1] == 1:
        B[a-1] = 2
            
ans = 0
for b in B:
    if b == 1:
        ans += 1

print(ans)

Buggy submission (verdict: Runtime Error):
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)

Buggy submission (verdict: Runtime Error):
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)

Buggy submission (verdict: Runtime Error):
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)

Buggy submission (verdict: Runtime Error):
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)

Buggy submission (verdict: Runtime Error):
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)

Buggy submission (verdict: Runtime Error):
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)

Buggy submission (verdict: Runtime Error):
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)