結果

問題 No.411 昇順昇順ソート
ユーザー tkw_techtkw_tech
提出日時 2016-08-12 23:00:18
言語 C++11
(gcc 11.4.0)
結果
WA  
実行時間 -
コード長 846 bytes
コンパイル時間 1,561 ms
コンパイル使用メモリ 157,928 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-25 05:39:10
合計ジャッジ時間 2,494 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 WA -
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 AC 2 ms
5,376 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 WA -
testcase_33 AC 2 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#define REP(i,n) for(ll i=0; i<(ll)(n); i++)
#define FOR(i,n,m) for (ll i=n; i<(ll)(m); i++)
#define pb push_back
#define INF 1000000007LL
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int,int> p;

int dy[4]={-1,1,0,0};
int dx[4]={0,0,1,-1};

int N , K;
ll C[40][40];
int main(){
    for(int i = 0; i <= 25; i ++) {
        C[i][0] = 1;
        for(int j = 1; j <= i; j ++) {
            C[i][j] = C[i-1][j-1] + C[i-1][j];
        }
    }
    
    cin >> N >> K;
    if (K==1){
        cout << N-1 << endl;
        return 0;
    }
    ll cnt = 1;
    REP(i,N-K) {
        //自分より大きいものをi+1個選ぶ
        cout << cnt << endl;
        cnt += C[N-K][i+1];
    }
    
    if (K==1) cout << cnt-1 << endl;
    else cout << cnt << endl;
    
    return 0;
}
0