結果

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

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
void Yes(){cout << "YES\n";}
void No(){cout << "NO\n";}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    auto nCr = [&](long long n,long long r) -> long long {
        if(n < r || n < 0 || r < 0) return 0;
        r = min(r,n-r);
        long long ret = 1;
        for(int i=1; i<=r; i++) ret *= n--,ret /= i;
        return ret;
    };

    int N; int i; cin >> N >> i;
    bool space = false;
    while(N > 0){
        if(space) cout << " ";
        space = true;
        if(i == 1){cout << N; break;}
        
        int now = i;
        while(true){
            now++;
            long long v = nCr(now,i);
            if(v > N) break; 
        }
        now--;
        cout << now;
        N -= nCr(now,i); i--;
    }
    cout << endl;
}
0