結果
| 問題 |
No.3030 Kruskal-Katona
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2025-02-21 22:11:11 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 912 bytes |
| コンパイル時間 | 2,178 ms |
| コンパイル使用メモリ | 194,572 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2025-02-21 22:11:15 |
| 合計ジャッジ時間 | 3,265 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 8 WA * 19 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
template<typename T>
T MUL(T a, T b){
T res;
return __builtin_mul_overflow(a, b, &res)? std::numeric_limits<T>::max() : res;
}
ll n, k;
long long int combination(long long int a, long long int b){
long long int ans = 1;
b = min(b, a - b);
for(int i = 0; i < b; i++){
ans = MUL(ans, a - b + i + 1);
ans /= i + 1;
if(ans > n) return (1ll << 60);
}
return ans;
}
int main(){
ios::sync_with_stdio(false);
cin.tie(0);
cin >> n >> k;
vector<ll> ans;
for(ll j = k; j >= 1; j--){
ll ok = 0, ng = n + 1;
while(ok + 1 < ng){
ll mid = (ok + ng) / 2;
(combination(mid, j) <= n ? ok : ng) = mid;
}
if(j != k) cout << ' ';
cout << ok;
n -= combination(ok, j);
if(n == 0) break;
}
cout << '\n';
}