結果

問題 No.1946 ロッカーの問題
ユーザー siganaisiganai
提出日時 2022-05-20 22:10:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 1,584 ms / 3,000 ms
コード長 1,014 bytes
コンパイル時間 240 ms
コンパイル使用メモリ 81,724 KB
実行使用メモリ 144,636 KB
最終ジャッジ日時 2023-10-20 12:52:42
合計ジャッジ時間 15,098 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 55 ms
63,776 KB
testcase_01 AC 56 ms
63,776 KB
testcase_02 AC 1,557 ms
131,856 KB
testcase_03 AC 1,584 ms
144,636 KB
testcase_04 AC 1,554 ms
131,848 KB
testcase_05 AC 1,028 ms
115,756 KB
testcase_06 AC 1,212 ms
121,112 KB
testcase_07 AC 861 ms
110,560 KB
testcase_08 AC 400 ms
93,164 KB
testcase_09 AC 1,369 ms
134,784 KB
testcase_10 AC 1,114 ms
125,696 KB
testcase_11 AC 101 ms
78,132 KB
testcase_12 AC 525 ms
98,396 KB
testcase_13 AC 55 ms
63,548 KB
testcase_14 AC 56 ms
63,548 KB
testcase_15 AC 143 ms
80,996 KB
testcase_16 AC 57 ms
63,780 KB
testcase_17 AC 628 ms
101,364 KB
testcase_18 AC 1,553 ms
131,700 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 i in range(1,n+1):
    div.append(divisor(i))
for i in range(1,n+1):
    for j in div[i-1]:
        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-1]:
            open[j] ^= 1
print(ans)
0