結果

問題 No.129 お年玉(2)
ユーザー peroonperoon
提出日時 2019-04-27 17:44:53
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 153 ms / 5,000 ms
コード長 1,002 bytes
コンパイル時間 1,225 ms
コンパイル使用メモリ 164,716 KB
実行使用メモリ 393,200 KB
最終ジャッジ日時 2023-08-18 18:17:31
合計ジャッジ時間 10,140 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 149 ms
393,200 KB
testcase_01 AC 149 ms
392,964 KB
testcase_02 AC 148 ms
393,152 KB
testcase_03 AC 148 ms
392,976 KB
testcase_04 AC 152 ms
392,896 KB
testcase_05 AC 148 ms
392,972 KB
testcase_06 AC 146 ms
392,880 KB
testcase_07 AC 146 ms
393,044 KB
testcase_08 AC 146 ms
392,900 KB
testcase_09 AC 146 ms
392,884 KB
testcase_10 AC 148 ms
393,008 KB
testcase_11 AC 148 ms
393,004 KB
testcase_12 AC 148 ms
392,952 KB
testcase_13 AC 146 ms
392,876 KB
testcase_14 AC 151 ms
393,120 KB
testcase_15 AC 148 ms
392,968 KB
testcase_16 AC 149 ms
393,008 KB
testcase_17 AC 151 ms
392,976 KB
testcase_18 AC 148 ms
392,964 KB
testcase_19 AC 149 ms
392,948 KB
testcase_20 AC 149 ms
393,020 KB
testcase_21 AC 147 ms
393,008 KB
testcase_22 AC 146 ms
392,952 KB
testcase_23 AC 146 ms
392,900 KB
testcase_24 AC 146 ms
392,912 KB
testcase_25 AC 145 ms
392,908 KB
testcase_26 AC 144 ms
392,980 KB
testcase_27 AC 147 ms
393,028 KB
testcase_28 AC 149 ms
393,044 KB
testcase_29 AC 146 ms
393,164 KB
testcase_30 AC 146 ms
393,004 KB
testcase_31 AC 150 ms
393,004 KB
testcase_32 AC 148 ms
392,904 KB
testcase_33 AC 149 ms
393,024 KB
testcase_34 AC 149 ms
392,956 KB
testcase_35 AC 148 ms
392,948 KB
testcase_36 AC 149 ms
393,196 KB
testcase_37 AC 149 ms
393,088 KB
testcase_38 AC 150 ms
392,968 KB
testcase_39 AC 151 ms
392,896 KB
testcase_40 AC 153 ms
392,960 KB
testcase_41 AC 148 ms
392,904 KB
testcase_42 AC 148 ms
392,948 KB
testcase_43 AC 150 ms
392,960 KB
testcase_44 AC 146 ms
393,020 KB
testcase_45 AC 148 ms
393,052 KB
testcase_46 AC 152 ms
392,900 KB
testcase_47 AC 147 ms
392,964 KB
testcase_48 AC 148 ms
393,104 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

// パスカルの三角形セット
const int N_MAX = 10010;
int pascal[N_MAX][N_MAX] = {};
void calc_pascal(){
    FOR(i, 0, N_MAX){
        pascal[i][0] = 1;
    }
    pascal[1][1] = 1;
    FOR(i, 2, N_MAX){
        for(int j=1; j<=i; j++){
            pascal[i][j] = pascal[i-1][j] + pascal[i-1][j-1];
            pascal[i][j] %= 1000000000; // 今回の問題用
        }
    }
}
int nCr(int n, int r){
    return pascal[n][r];
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    // input
    ll N, M;
    cin >> N >> M;

    N /= 1000;
    ll rest = N%M;

    calc_pascal();
    ll ans = nCr(M, rest);
    p(ans);
    
    return 0;
}
0