結果

問題 No.1946 ロッカーの問題
ユーザー hashi_pyhashi_py
提出日時 2022-05-20 22:23:51
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,105 ms / 3,000 ms
コード長 763 bytes
コンパイル時間 170 ms
コンパイル使用メモリ 81,712 KB
実行使用メモリ 125,272 KB
最終ジャッジ日時 2023-10-20 13:08:55
合計ジャッジ時間 7,352 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 37 ms
53,484 KB
testcase_01 AC 37 ms
53,484 KB
testcase_02 AC 1,105 ms
77,108 KB
testcase_03 AC 357 ms
125,272 KB
testcase_04 AC 1,096 ms
77,124 KB
testcase_05 AC 724 ms
77,144 KB
testcase_06 AC 843 ms
77,292 KB
testcase_07 AC 608 ms
77,088 KB
testcase_08 AC 140 ms
90,972 KB
testcase_09 AC 334 ms
119,840 KB
testcase_10 AC 287 ms
112,640 KB
testcase_11 AC 67 ms
70,756 KB
testcase_12 AC 313 ms
79,372 KB
testcase_13 AC 37 ms
53,484 KB
testcase_14 AC 36 ms
53,484 KB
testcase_15 AC 96 ms
75,704 KB
testcase_16 AC 37 ms
53,484 KB
testcase_17 AC 66 ms
84,132 KB
testcase_18 AC 89 ms
104,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

def divisors(N):
    #Nの約数列挙
    divisors = []
    for i in range(1, N + 1):
        if i * i > N:
            break
        if N % i == 0:
            divisors.append(i)
            if N != i * i:
                divisors.append(N // i)
    return divisors

savotaged = [0]*(n+1)
ans = 0
for i in range(n-1,-1,-1):
    cnt = n//(i+1)
    if(cnt + savotaged[i+1])%2==0:
        if(i+1 in a):
            ans+=1
            for num in divisors(i+1):
                savotaged[num]^=1
        else:
            continue
    else:
        if(i+1 in a):
            continue
        else:
            ans+=1
            for num in divisors(i+1):
                savotaged[num]^=1

print(ans)
0