結果

問題 No.1946 ロッカーの問題
ユーザー siganaisiganai
提出日時 2022-05-21 01:24:14
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 621 ms / 3,000 ms
コード長 1,060 bytes
コンパイル時間 1,046 ms
コンパイル使用メモリ 81,820 KB
実行使用メモリ 145,468 KB
最終ジャッジ日時 2023-10-20 15:25:56
合計ジャッジ時間 6,671 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
63,360 KB
testcase_01 AC 55 ms
63,360 KB
testcase_02 AC 621 ms
135,648 KB
testcase_03 AC 601 ms
145,468 KB
testcase_04 AC 596 ms
135,648 KB
testcase_05 AC 368 ms
116,208 KB
testcase_06 AC 450 ms
121,328 KB
testcase_07 AC 302 ms
102,168 KB
testcase_08 AC 160 ms
91,264 KB
testcase_09 AC 512 ms
137,292 KB
testcase_10 AC 431 ms
121,116 KB
testcase_11 AC 73 ms
73,156 KB
testcase_12 AC 188 ms
95,476 KB
testcase_13 AC 56 ms
63,360 KB
testcase_14 AC 55 ms
63,360 KB
testcase_15 AC 86 ms
80,388 KB
testcase_16 AC 55 ms
63,360 KB
testcase_17 AC 199 ms
96,000 KB
testcase_18 AC 565 ms
135,052 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#!/usr/bin/env PyPy3

from collections import Counter, defaultdict, deque
import itertools
import re
import math
from functools import reduce
import operator
import bisect
from heapq import *
import functools
mod=998244353

import sys
input=sys.stdin.readline
def divisor(n):
    sq = n**0.5
    border = int(sq)
    table = []
    bigs = []
    for small in range(1, border+1):
        if n%small == 0:
            table.append(small)
            big = n//small
            bigs.append(big)
    if border == sq:#nが平方数
        bigs.pop()
    table += reversed(bigs)
    return table
n,m=map(int,input().split())
a=list(map(int,input().split()))

open = [0] * (n+1)
div = [[] for _ in range(n+1)]
for i in range(1,n+1):
    for j in range(i,n+1,i):
        div[j].append(i)
for i in range(1,n+1):
    for j in div[i]:
        open[j] ^= 1
fact = [0] * (n+1)
for aa in a:
    fact[aa] = 1
ans = 0


for i in range(1,n+1)[::-1]:
    #print(open,fact)
    if fact[i] != open[i]:
        ans += 1
        for j in div[i]:
            open[j] ^= 1
print(ans)
0