結果

問題 No.2118 遺伝的有限集合の数え上げ
ユーザー flygonflygon
提出日時 2022-11-04 21:57:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 103 ms / 2,000 ms
コード長 456 bytes
コンパイル時間 351 ms
コンパイル使用メモリ 87,236 KB
実行使用メモリ 72,620 KB
最終ジャッジ日時 2023-09-26 00:21:27
合計ジャッジ時間 5,927 ms
ジャッジサーバーID
(参考情報)
judge15 / judge11
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
72,540 KB
testcase_01 AC 97 ms
72,396 KB
testcase_02 AC 98 ms
72,408 KB
testcase_03 AC 97 ms
72,544 KB
testcase_04 AC 95 ms
72,340 KB
testcase_05 AC 97 ms
72,448 KB
testcase_06 AC 95 ms
72,284 KB
testcase_07 AC 96 ms
72,420 KB
testcase_08 AC 97 ms
72,468 KB
testcase_09 AC 99 ms
72,448 KB
testcase_10 AC 99 ms
72,284 KB
testcase_11 AC 100 ms
72,592 KB
testcase_12 AC 100 ms
72,452 KB
testcase_13 AC 103 ms
72,400 KB
testcase_14 AC 101 ms
72,424 KB
testcase_15 AC 103 ms
72,376 KB
testcase_16 AC 101 ms
72,424 KB
testcase_17 AC 101 ms
72,512 KB
testcase_18 AC 98 ms
72,224 KB
testcase_19 AC 101 ms
72,340 KB
testcase_20 AC 101 ms
72,432 KB
testcase_21 AC 99 ms
72,444 KB
testcase_22 AC 98 ms
72,488 KB
testcase_23 AC 98 ms
72,376 KB
testcase_24 AC 100 ms
72,424 KB
testcase_25 AC 101 ms
72,428 KB
testcase_26 AC 101 ms
72,348 KB
testcase_27 AC 98 ms
72,456 KB
testcase_28 AC 101 ms
72,376 KB
testcase_29 AC 99 ms
72,620 KB
testcase_30 AC 101 ms
72,380 KB
testcase_31 AC 101 ms
72,492 KB
testcase_32 AC 102 ms
72,220 KB
testcase_33 AC 100 ms
72,308 KB
testcase_34 AC 98 ms
72,404 KB
testcase_35 AC 101 ms
72,512 KB
testcase_36 AC 100 ms
72,400 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from functools import lru_cache
@lru_cache(maxsize=None)
def f(n):
  ans = [0]
  use = []
  now = 0
  while n != 0:
    if n & 1:
      use.append(now)
    now += 1
    n >>= 1
  for i in use:
    ans += f(i)
    ans.append(2)
  if ans[-1] == 2:
    ans.pop()
  ans.append(1)
  return ans

ans = f(int(input()))
for i in range(len(ans)):
  if ans[i] == 0:
    ans[i] = "{"
  elif ans[i] == 1:
    ans[i] = "}"
  else:
    ans[i] = ","

print("".join(ans))
0