結果
問題 | No.1059 素敵な集合 |
ユーザー | 6soukiti29 |
提出日時 | 2020-05-31 13:40:22 |
言語 | Nim (2.0.2) |
結果 |
AC
|
実行時間 | 41 ms / 2,000 ms |
コード長 | 1,249 bytes |
コンパイル時間 | 4,351 ms |
コンパイル使用メモリ | 68,336 KB |
実行使用メモリ | 6,252 KB |
最終ジャッジ日時 | 2023-09-30 15:38:52 |
合計ジャッジ時間 | 5,273 ms |
ジャッジサーバーID (参考情報) |
judge14 / judge15 |
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 4 ms
6,092 KB |
testcase_01 | AC | 29 ms
6,140 KB |
testcase_02 | AC | 6 ms
6,108 KB |
testcase_03 | AC | 5 ms
6,248 KB |
testcase_04 | AC | 4 ms
6,248 KB |
testcase_05 | AC | 4 ms
6,188 KB |
testcase_06 | AC | 6 ms
6,252 KB |
testcase_07 | AC | 6 ms
6,076 KB |
testcase_08 | AC | 7 ms
6,244 KB |
testcase_09 | AC | 4 ms
6,072 KB |
testcase_10 | AC | 11 ms
6,244 KB |
testcase_11 | AC | 7 ms
6,248 KB |
testcase_12 | AC | 5 ms
6,248 KB |
testcase_13 | AC | 10 ms
6,072 KB |
testcase_14 | AC | 4 ms
6,220 KB |
testcase_15 | AC | 16 ms
6,128 KB |
testcase_16 | AC | 7 ms
6,128 KB |
testcase_17 | AC | 6 ms
6,132 KB |
testcase_18 | AC | 5 ms
6,072 KB |
testcase_19 | AC | 41 ms
6,076 KB |
testcase_20 | AC | 39 ms
6,116 KB |
testcase_21 | AC | 15 ms
6,140 KB |
ソースコード
import sequtils,strutils var L, R, ans : int (L, R) = stdin.readline.split.map(parseInt) type unionfindtree[I : static[int]] = array[I,int] proc initUT(I : static[int]):unionfindtree[I] = var res : unionfindtree[I] for i in 0..<I: res[i] = i return res proc find(U : var unionfindtree; a : int, b :int): bool= var s = a t = b while s != U[s]: s = U[s] while t != U[t]: t = U[t] var s2 = a t2 = b p : int while s2 != s: p = U[s2] U[s2] = s s2 = p while t2 != t: p = U[t2] U[t2] = t t2 = p return s == t proc union(U : var unionfindtree; a : int ; b : int)= if U.find(a,b): return var s = a t = b t2 : int while s != U[s]: s = U[s] while t != U[t]: t2 = U[t] U[t] = s t = t2 U[t] = s proc root(U : unionfindtree, a :int):int= var s = a while s != U[s]: s = U[s] return s var A = initUT(200010) for i in L..R: for j in 2..200010: if i * j > R: break A.union(i, i * j) for i in L..R: if A[i] == i: ans += 1 echo ans - 1