結果

問題 No.1946 ロッカーの問題
ユーザー june19312june19312
提出日時 2022-05-21 00:00:55
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 146 ms / 3,000 ms
コード長 620 bytes
コンパイル時間 420 ms
コンパイル使用メモリ 81,712 KB
実行使用メモリ 108,856 KB
最終ジャッジ日時 2023-10-20 14:55:18
合計ジャッジ時間 2,393 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,360 KB
testcase_01 AC 38 ms
53,360 KB
testcase_02 AC 38 ms
53,360 KB
testcase_03 AC 146 ms
108,856 KB
testcase_04 AC 83 ms
69,376 KB
testcase_05 AC 75 ms
72,792 KB
testcase_06 AC 77 ms
75,128 KB
testcase_07 AC 70 ms
72,480 KB
testcase_08 AC 75 ms
82,700 KB
testcase_09 AC 123 ms
104,924 KB
testcase_10 AC 113 ms
101,088 KB
testcase_11 AC 60 ms
68,420 KB
testcase_12 AC 95 ms
77,932 KB
testcase_13 AC 38 ms
53,360 KB
testcase_14 AC 37 ms
53,360 KB
testcase_15 AC 51 ms
62,472 KB
testcase_16 AC 38 ms
53,360 KB
testcase_17 AC 87 ms
84,140 KB
testcase_18 AC 128 ms
99,448 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

if M == 0:
    print(N)
    exit()

A = list(map(int,input().split()))
B = [False]*(N+1)

for i,v in enumerate(A):
    B[v] = True

#print("B",B)
ans = [0]*(N+1)
tmp = N//2+1

for i,v in enumerate(B):
    if v and i>=tmp:
        ans[i] = 1

#print(ans)

for i in range(tmp-1,0,-1):
    
    
    tmp2 = N//i
#    print("i=",i,"tmp2",tmp2)
    cnt = 0

    for j in range(tmp2):
        if ans[i*(j+1)] == 1:
            cnt+=1

#    print("cnt",cnt)
    
    if cnt%2 == 0 and B[i]:
        ans[i] = 1
    elif cnt%2 == 1 and not B[i]:
        ans[i] = 1


print(N-sum(ans))
#print(ans)
0