結果

問題 No.3030 Kruskal-Katona
ユーザー Carpenters-Cat
提出日時 2025-02-21 22:59:35
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 569 bytes
コンパイル時間 2,368 ms
コンパイル使用メモリ 195,588 KB
実行使用メモリ 6,820 KB
最終ジャッジ日時 2025-02-21 22:59:44
合計ジャッジ時間 3,292 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 27
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Vl = std::vector<ll> ;
void calc(ll N, int i, Vl& A, int up = (int)(1e8 + 6)) {
	if (N == 0) {
		return;
	}
	if (i == 1) {
		A.push_back(N);
		return;
	}
	ll p = 1, s = 1;
	ll n = i;
	while ((s <= N) && (n < up)) {
		p = s;
		s *= (n + 1);
		s /= (n - i + 1);
		n ++;
	}
	n --;
	A.push_back(n);
	calc(N - p, i-1, A, n);
	return;
}
int main () {
	int N, i;
	cin >> N >> i;
	Vl ans;
	calc(N, i, ans);
	for (int i = 0; i < ans.size(); i ++) {
		cout << (i ? " " : "") << ans[i];
	}
	cout << endl;
}
0