結果

問題 No.1946 ロッカーの問題
ユーザー H20H20
提出日時 2022-03-19 23:42:49
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,545 ms / 3,000 ms
コード長 701 bytes
コンパイル時間 171 ms
コンパイル使用メモリ 82,716 KB
実行使用メモリ 131,944 KB
最終ジャッジ日時 2024-06-01 06:28:38
合計ジャッジ時間 14,686 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
52,620 KB
testcase_01 AC 37 ms
52,468 KB
testcase_02 AC 1,506 ms
130,072 KB
testcase_03 AC 1,545 ms
131,944 KB
testcase_04 AC 1,510 ms
130,204 KB
testcase_05 AC 999 ms
114,048 KB
testcase_06 AC 1,162 ms
119,552 KB
testcase_07 AC 837 ms
108,644 KB
testcase_08 AC 373 ms
92,024 KB
testcase_09 AC 1,327 ms
124,148 KB
testcase_10 AC 1,083 ms
117,696 KB
testcase_11 AC 78 ms
77,488 KB
testcase_12 AC 498 ms
95,240 KB
testcase_13 AC 38 ms
53,504 KB
testcase_14 AC 37 ms
53,008 KB
testcase_15 AC 110 ms
78,172 KB
testcase_16 AC 39 ms
52,800 KB
testcase_17 AC 601 ms
99,688 KB
testcase_18 AC 1,520 ms
129,552 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def make_divisors(n):
    lower_divisors , upper_divisors = [], []
    i = 1
    while i*i <= n:
        if n % i == 0:
            lower_divisors.append(i)
            if i != n // i:
                upper_divisors.append(n//i)
        i += 1
    return lower_divisors + upper_divisors[::-1]

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

DIV = [[]]
ALL = [0]*(N+1)
DOOR= [0]*(N+1)
for i in range(1,N+1):
    DIV.append(make_divisors(i))
    for div in DIV[i]:
        ALL[div] = (ALL[div]+1)%2
for a in A:
    DOOR[a]=1

cnt = 0
for i in reversed(range(N+1)):
    if ALL[i]!=DOOR[i]:
        cnt+=1
        for div in DIV[i]:
            DOOR[div] = (DOOR[div]+1)%2
print(cnt)
0