結果

問題 No.3030 Kruskal-Katona
ユーザー nasutarou1341
提出日時 2025-02-21 21:58:58
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 1,381 bytes
コンパイル時間 287 ms
コンパイル使用メモリ 81,948 KB
実行使用メモリ 76,292 KB
最終ジャッジ日時 2025-02-21 21:59:01
合計ジャッジ時間 2,901 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 8 WA * 19
権限があれば一括ダウンロードができます

ソースコード

diff #

def com(n, c):
  a = 1
  for i in range(c):
    a *= n - i
    a //= i + 1
  return a

class nibutan:
  @staticmethod
  def nibutan(ok, ng, op):
    while abs(ok - ng) > 1:
      mid = (ok + ng) // 2
      if op(mid):
        ok = mid
      else:
        ng = mid
    return ok
  @staticmethod
  def lt(L, n):
    """Lのうちn未満の最大の要素"""
    if L[0] >= n: return -1
    def op(mid):
      return L[mid] < n 
    ok = 0
    ng = len(L)
    return nibutan.nibutan(ok, ng, op)

  @staticmethod
  def le(L, n):
    """Lのうちn以下の最大の要素"""
    if L[0] > n: return -1
    def op(mid):
      return L[mid] <= n 
    ok = 0
    ng = len(L)
    return nibutan.nibutan(ok, ng, op)
      
  @staticmethod
  def gt(L, n):
    """Lのうちn超過の最小の要素"""
    if L[-1] <= n: return len(L)
    def op(mid):
      return L[mid] > n 
    ok = len(L) - 1
    ng = -1
    return nibutan.nibutan(ok, ng, op)
      
  @staticmethod
  def ge(L, n):
    """Lのうちn以上の最小の要素"""
    if L[-1] < n: return len(L)
    def op(mid):
      return L[mid] >= n 
    ok = len(L) - 1
    ng = -1
    return nibutan.nibutan(ok, ng, op)
  
N, i = list(map(int, input().split()))

def op(mid):
  return com(mid, i) <= N

ans = []
while N:
  ok = 0
  ng = N + 1
  a = nibutan.nibutan(ok, ng, op)
  N -= com(a, i)
  ans.append(a)
  i -= 1

print(*ans)
0