結果

問題 No.1946 ロッカーの問題
ユーザー abababab
提出日時 2022-05-20 22:37:19
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,036 ms / 3,000 ms
コード長 513 bytes
コンパイル時間 177 ms
コンパイル使用メモリ 81,696 KB
実行使用メモリ 125,276 KB
最終ジャッジ日時 2023-10-20 13:23:33
合計ジャッジ時間 5,756 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
53,508 KB
testcase_01 AC 40 ms
53,508 KB
testcase_02 AC 46 ms
63,200 KB
testcase_03 AC 855 ms
125,276 KB
testcase_04 AC 47 ms
63,256 KB
testcase_05 AC 76 ms
73,744 KB
testcase_06 AC 79 ms
74,352 KB
testcase_07 AC 74 ms
73,600 KB
testcase_08 AC 239 ms
90,628 KB
testcase_09 AC 738 ms
119,760 KB
testcase_10 AC 618 ms
112,612 KB
testcase_11 AC 75 ms
73,632 KB
testcase_12 AC 172 ms
78,972 KB
testcase_13 AC 40 ms
53,508 KB
testcase_14 AC 40 ms
53,508 KB
testcase_15 AC 44 ms
59,804 KB
testcase_16 AC 39 ms
53,508 KB
testcase_17 AC 424 ms
90,960 KB
testcase_18 AC 1,036 ms
109,072 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def div_lis(x):
    div_l, div_r = [], []
    i = 1
    while i * i <= x:
        if x % i == 0:
            div_l.append(i)
            if i != x // i:
                div_r.append(x // i)
        i += 1
    div = div_l + div_r[::-1]
    return div


n, m = map(int, input().split())
A = set(map(int, input().split()))

open_ = [0] * (n + 1)
ans = 0
for x in reversed(range(1, n + 1)):
    if (x in A) != open_[x]:
        for div in div_lis(x):
            open_[div] ^= 1
    else:
        ans += 1

print(ans)
0