結果

問題 No.1946 ロッカーの問題
ユーザー 👑 H20H20
提出日時 2022-04-10 18:54:05
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,599 ms / 3,000 ms
コード長 856 bytes
コンパイル時間 277 ms
コンパイル使用メモリ 86,868 KB
実行使用メモリ 135,652 KB
最終ジャッジ日時 2023-08-23 08:50:35
合計ジャッジ時間 15,637 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,512 KB
testcase_01 AC 71 ms
71,072 KB
testcase_02 AC 1,566 ms
130,940 KB
testcase_03 AC 1,599 ms
134,760 KB
testcase_04 AC 1,558 ms
130,948 KB
testcase_05 AC 1,033 ms
115,052 KB
testcase_06 AC 1,197 ms
120,208 KB
testcase_07 AC 875 ms
109,924 KB
testcase_08 AC 415 ms
97,248 KB
testcase_09 AC 1,404 ms
128,552 KB
testcase_10 AC 1,129 ms
119,388 KB
testcase_11 AC 106 ms
78,864 KB
testcase_12 AC 526 ms
96,692 KB
testcase_13 AC 70 ms
71,412 KB
testcase_14 AC 71 ms
71,388 KB
testcase_15 AC 141 ms
79,200 KB
testcase_16 AC 70 ms
71,256 KB
testcase_17 AC 641 ms
100,292 KB
testcase_18 AC 1,574 ms
135,652 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()))
if not (1<=N<=2*10**5 and 0<=M<=N and len(A)==M and A==sorted(A) and M == len(set(A))):
    exit()
for a in A:
    if 1<=a<=N:
        continue
    exit()

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