結果

問題 No.1946 ロッカーの問題
ユーザー terasaterasa
提出日時 2022-05-21 20:16:12
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 240 ms / 3,000 ms
コード長 872 bytes
コンパイル時間 153 ms
コンパイル使用メモリ 81,900 KB
実行使用メモリ 145,956 KB
最終ジャッジ日時 2023-10-20 16:36:54
合計ジャッジ時間 3,717 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 58 ms
66,304 KB
testcase_01 AC 54 ms
66,304 KB
testcase_02 AC 197 ms
120,920 KB
testcase_03 AC 240 ms
145,956 KB
testcase_04 AC 203 ms
120,920 KB
testcase_05 AC 170 ms
102,496 KB
testcase_06 AC 195 ms
113,504 KB
testcase_07 AC 165 ms
104,944 KB
testcase_08 AC 134 ms
92,612 KB
testcase_09 AC 231 ms
136,188 KB
testcase_10 AC 204 ms
125,632 KB
testcase_11 AC 88 ms
79,748 KB
testcase_12 AC 142 ms
95,208 KB
testcase_13 AC 56 ms
66,304 KB
testcase_14 AC 56 ms
66,304 KB
testcase_15 AC 79 ms
79,880 KB
testcase_16 AC 55 ms
66,304 KB
testcase_17 AC 135 ms
95,208 KB
testcase_18 AC 222 ms
132,492 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys
import pypyjit
import itertools
import heapq
import math
from collections import deque, defaultdict, Counter
import string
import random

input = sys.stdin.readline
sys.setrecursionlimit(10 ** 6)
pypyjit.set_param('max_unroll_recursion=-1')


N, M = map(int, input().split())
A = list(map(int, input().split()))

divs = [[] for _ in range(N + 1)]
for i in range(1, N + 1):
    for j in range(1, N + 1):
        if i * j > N:
            break
        divs[i].append(i * j)

actual = [False] * (N + 1)
for a in A:
    actual[a] = True

done = [None] * (N + 1)
ans = 0
for i in range(1, N + 1)[::-1]:
    expected = True
    for j in divs[i]:
        if i == j:
            continue
        if done[j]:
            expected = not expected
    done[i] = expected is actual[i]

ans = 0
for i in range(1, N + 1):
    if done[i] is False:
        ans += 1
print(ans)
0