結果

問題 No.3030 Kruskal-Katona
ユーザー Andrew8128
提出日時 2025-02-21 22:26:04
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 968 ms / 2,000 ms
コード長 982 bytes
コンパイル時間 6,747 ms
コンパイル使用メモリ 462,072 KB
実行使用メモリ 172,416 KB
最終ジャッジ日時 2025-02-21 22:26:19
合計ジャッジ時間 14,006 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#include <boost/multiprecision/cpp_int.hpp>
typedef boost::multiprecision::cpp_int bint;
#pragma GCC optimize("O3")
int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  vector<bint> fact(14200);
  fact[0] = fact[1] = 1;
  for (int i = 2; i < 14200; i++) {
    fact[i] = fact[i-1] * i;
  }
  auto comb = [&fact](int n, int r){
    return fact[n] / fact[r] / fact[n-r];
  };

  bint N;
  int i;
  cin >> N >> i;
  vector<int> ans;
  for (; 1 <= i; i--) {
    if(i == 1){
      ans.push_back((int)N);
      break;
    }
    auto j = i;
    while(1){
      if(comb(j, i) <= N){
        j++;
      }else{
        ans.push_back(j-1);
        N -= comb(j-1, i);
        break;
      }
    }
    if(N == 0) break;
  }
  for (int i = 0; i < ssize(ans); i++) {
    if(i) cout << ' ';
    cout << ans[i];
  }
  cout << '\n';
  return 0;
}
/*
  File : ~/yukicoder/528/D.cpp
  Date : 2025/02/21
  Time : 22:00:54
*/
0