結果
問題 | No.1946 ロッカーの問題 |
ユーザー | hir355 |
提出日時 | 2022-05-20 21:49:55 |
言語 | PyPy3 (7.3.15) |
結果 |
AC
|
実行時間 | 214 ms / 3,000 ms |
コード長 | 1,312 bytes |
コンパイル時間 | 251 ms |
コンパイル使用メモリ | 81,688 KB |
実行使用メモリ | 110,404 KB |
最終ジャッジ日時 | 2023-10-20 12:21:57 |
合計ジャッジ時間 | 3,298 ms |
ジャッジサーバーID (参考情報) |
judge15 / judge13 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 47 ms
60,948 KB |
testcase_01 | AC | 47 ms
60,948 KB |
testcase_02 | AC | 214 ms
80,508 KB |
testcase_03 | AC | 169 ms
110,404 KB |
testcase_04 | AC | 214 ms
80,512 KB |
testcase_05 | AC | 180 ms
79,916 KB |
testcase_06 | AC | 188 ms
80,096 KB |
testcase_07 | AC | 165 ms
79,552 KB |
testcase_08 | AC | 106 ms
87,220 KB |
testcase_09 | AC | 147 ms
106,824 KB |
testcase_10 | AC | 141 ms
103,060 KB |
testcase_11 | AC | 81 ms
77,716 KB |
testcase_12 | AC | 118 ms
79,856 KB |
testcase_13 | AC | 48 ms
60,952 KB |
testcase_14 | AC | 47 ms
60,952 KB |
testcase_15 | AC | 90 ms
77,712 KB |
testcase_16 | AC | 47 ms
60,952 KB |
testcase_17 | AC | 67 ms
80,364 KB |
testcase_18 | AC | 85 ms
97,968 KB |
ソースコード
class osa_k: min_factor = [] def __init__(self, n): self.min_factor = list(range(n + 1)) i = 2 while i * i <= n: if self.min_factor[i] < i: i += 1 continue for j in range(i*i, n + 1, i): if self.min_factor[j] == j: self.min_factor[j] = i i += 1 def factor(self, n): res = [] while n > 1: res.append(self.min_factor[n]) n //= self.min_factor[n] return res def divisors(self, n): res = [1] while n > 1: x = self.min_factor[n] cnt = 0 while n % x == 0: cnt += 1 n //= x t = [] p = 1 for i in range(cnt + 1): for j in range(len(res)): t.append(res[j] * p) p *= x res = t[:] return res osk = osa_k(200000) n, m = map(int, input().split()) d = [0] * (n + 1) d2 = [0] * (n + 1) a = list(map(int, input().split())) for x in a: d2[x] = 1 for i in range(1, n + 1): d[i] = (n // i) % 2 ans = 0 for i in range(n, 0, -1): if d[i] != d2[i]: ans += 1 for dv in osk.divisors(i): d[dv] ^= 1 print(ans)