結果
問題 | No.1059 素敵な集合 |
ユーザー | c-yan |
提出日時 | 2020-05-23 08:47:12 |
言語 | Python3 (3.12.2 + numpy 1.26.4 + scipy 1.12.0) |
結果 |
AC
|
実行時間 | 308 ms / 2,000 ms |
コード長 | 620 bytes |
コンパイル時間 | 449 ms |
コンパイル使用メモリ | 11,004 KB |
実行使用メモリ | 10,104 KB |
最終ジャッジ日時 | 2023-09-30 15:36:28 |
合計ジャッジ時間 | 3,200 ms |
ジャッジサーバーID (参考情報) |
judge11 / judge15 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 16 ms
7,788 KB |
testcase_01 | AC | 136 ms
9,544 KB |
testcase_02 | AC | 73 ms
9,016 KB |
testcase_03 | AC | 16 ms
7,784 KB |
testcase_04 | AC | 16 ms
7,868 KB |
testcase_05 | AC | 16 ms
7,960 KB |
testcase_06 | AC | 57 ms
8,892 KB |
testcase_07 | AC | 56 ms
8,540 KB |
testcase_08 | AC | 74 ms
9,020 KB |
testcase_09 | AC | 29 ms
8,388 KB |
testcase_10 | AC | 89 ms
8,776 KB |
testcase_11 | AC | 60 ms
8,816 KB |
testcase_12 | AC | 40 ms
8,620 KB |
testcase_13 | AC | 105 ms
9,312 KB |
testcase_14 | AC | 19 ms
8,216 KB |
testcase_15 | AC | 175 ms
9,716 KB |
testcase_16 | AC | 66 ms
8,748 KB |
testcase_17 | AC | 68 ms
9,036 KB |
testcase_18 | AC | 61 ms
9,532 KB |
testcase_19 | AC | 308 ms
9,524 KB |
testcase_20 | AC | 288 ms
9,804 KB |
testcase_21 | AC | 179 ms
10,104 KB |
ソースコード
from sys import setrecursionlimit def find(parent, i): t = parent[i] if t < 0: return i t = find(parent, t) parent[i] = t return t def unite(parent, i, j): i = find(parent, i) j = find(parent, j) if i == j: return if i > j: i, j = j, i parent[i] += parent[j] parent[j] = i setrecursionlimit(10 ** 6) L, R = map(int, input().split()) parent = [-1] * (R + 1) for i in range(L, R): if parent[i] >= 0: continue for j in range(i * 2, R + 1, i): unite(parent, i, j) print(sum(1 for i in range(L, R + 1) if parent[i] < 0) - 1)