結果

問題 No.1946 ロッカーの問題
ユーザー akasia_midoriakasia_midori
提出日時 2022-05-21 12:04:50
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 901 ms / 3,000 ms
コード長 870 bytes
コンパイル時間 853 ms
コンパイル使用メモリ 81,792 KB
実行使用メモリ 122,340 KB
最終ジャッジ日時 2023-10-20 15:52:59
合計ジャッジ時間 7,394 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
53,704 KB
testcase_01 AC 32 ms
53,704 KB
testcase_02 AC 901 ms
104,192 KB
testcase_03 AC 317 ms
121,112 KB
testcase_04 AC 892 ms
104,200 KB
testcase_05 AC 633 ms
95,356 KB
testcase_06 AC 735 ms
98,260 KB
testcase_07 AC 522 ms
92,980 KB
testcase_08 AC 116 ms
93,112 KB
testcase_09 AC 290 ms
115,596 KB
testcase_10 AC 242 ms
120,916 KB
testcase_11 AC 56 ms
71,040 KB
testcase_12 AC 262 ms
88,160 KB
testcase_13 AC 32 ms
53,508 KB
testcase_14 AC 35 ms
53,508 KB
testcase_15 AC 87 ms
76,976 KB
testcase_16 AC 33 ms
53,508 KB
testcase_17 AC 66 ms
92,492 KB
testcase_18 AC 92 ms
122,340 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def oi(): return int(input())
def os(): return input()
def mi(): return list(map(int, input().split()))

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

input_count = 0
N, M = mi()
A = mi()
NA = [1]*N

C = []
for i in range(1,N+1):
    if (N//i)%2==0:
        C.append(1)
    else:
        C.append(-1)

for a in A:
    NA[a-1] = -1

hoge = []
for c, nn in zip(C, NA):
    if c!=nn:
        hoge.append(1)
    else:
        hoge.append(0)

count = 0
for i in range(N-1, -1, -1):
    if hoge[i]==1:
        count += 1
        for j in make_divisors(i+1):
            if hoge[j-1] == 0:
                hoge[j-1] = 1
            else:
                hoge[j-1] = 0

print(count)
0