結果

問題 No.1946 ロッカーの問題
ユーザー pitP
提出日時 2022-05-20 22:09:17
言語 Python3
(3.13.1 + numpy 2.2.1 + scipy 1.14.1)
結果
AC  
実行時間 964 ms / 3,000 ms
コード長 358 bytes
コンパイル時間 154 ms
コンパイル使用メモリ 12,672 KB
実行使用メモリ 30,292 KB
最終ジャッジ日時 2024-09-20 08:19:40
合計ジャッジ時間 9,575 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

n,m = map(int,input().split())
a = list(map(int,input().split()))
g = [0] * (n+1)
for i in range(m):
    g[a[i]] = 1

boo = [1] * (n+1) #サボったら0

ans = 0
for i in range(n,0,-1):
    coef = 1
    cnt = 0
    while i * coef <= n:
        cnt += boo[i * coef]
        coef += 1
    
    if cnt%2 != g[i]:
        boo[i] = 0
        ans += 1

print(ans)
0