結果

問題 No.1946 ロッカーの問題
ユーザー AkariAkari
提出日時 2022-05-20 22:54:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,152 ms / 3,000 ms
コード長 767 bytes
コンパイル時間 167 ms
コンパイル使用メモリ 81,740 KB
実行使用メモリ 123,736 KB
最終ジャッジ日時 2023-10-20 13:45:22
合計ジャッジ時間 11,062 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 38 ms
53,488 KB
testcase_01 AC 38 ms
53,488 KB
testcase_02 AC 1,093 ms
123,160 KB
testcase_03 AC 1,152 ms
123,736 KB
testcase_04 AC 1,082 ms
123,164 KB
testcase_05 AC 745 ms
108,964 KB
testcase_06 AC 868 ms
112,064 KB
testcase_07 AC 629 ms
104,068 KB
testcase_08 AC 291 ms
88,860 KB
testcase_09 AC 996 ms
117,272 KB
testcase_10 AC 809 ms
111,156 KB
testcase_11 AC 68 ms
72,584 KB
testcase_12 AC 383 ms
93,652 KB
testcase_13 AC 38 ms
53,488 KB
testcase_14 AC 37 ms
53,488 KB
testcase_15 AC 98 ms
78,332 KB
testcase_16 AC 41 ms
53,488 KB
testcase_17 AC 451 ms
95,028 KB
testcase_18 AC 1,133 ms
122,536 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import sys

def divisors_list(n):
    divisors = [1]
    if n != 1:
        divisors.append(n)
    i = 2
    while i * i <= n:
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n // i)
        i += 1
    return divisors


def main():
    n, m = map(int, input().split())
    idx = list(map(int, input().split()))
    B = [0] * (n + 1)
    for i in idx: B[i] = 1
    A = [0] * (n + 1)
    D = [[]]
    for i in range(1, n + 1):
        d = divisors_list(i)
        D.append(d)
        for j in d: A[j] ^= 1
    ans = 0
    for i in range(n, 0, -1):
        if A[i] != B[i]:
            ans += 1
            d = D[i]
            for j in d: A[j] ^= 1
    print(ans)


if __name__ == '__main__':
    main()
0