結果

問題 No.129 お年玉(2)
ユーザー なおなお
提出日時 2015-01-16 23:35:49
言語 C++11
(gcc 11.4.0)
結果
AC  
実行時間 663 ms / 5,000 ms
コード長 637 bytes
コンパイル時間 2,709 ms
コンパイル使用メモリ 149,232 KB
実行使用メモリ 100,996 KB
最終ジャッジ日時 2023-08-18 16:24:44
合計ジャッジ時間 15,766 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 29 ms
8,684 KB
testcase_01 AC 2 ms
4,380 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,380 KB
testcase_04 AC 1 ms
4,380 KB
testcase_05 AC 185 ms
43,620 KB
testcase_06 AC 408 ms
67,420 KB
testcase_07 AC 538 ms
81,840 KB
testcase_08 AC 177 ms
56,680 KB
testcase_09 AC 483 ms
75,584 KB
testcase_10 AC 538 ms
84,704 KB
testcase_11 AC 310 ms
54,496 KB
testcase_12 AC 151 ms
70,384 KB
testcase_13 AC 127 ms
73,536 KB
testcase_14 AC 449 ms
71,144 KB
testcase_15 AC 349 ms
58,936 KB
testcase_16 AC 368 ms
66,760 KB
testcase_17 AC 487 ms
80,304 KB
testcase_18 AC 479 ms
75,884 KB
testcase_19 AC 310 ms
80,780 KB
testcase_20 AC 477 ms
80,196 KB
testcase_21 AC 619 ms
99,612 KB
testcase_22 AC 347 ms
57,300 KB
testcase_23 AC 569 ms
87,228 KB
testcase_24 AC 195 ms
83,860 KB
testcase_25 AC 289 ms
54,916 KB
testcase_26 AC 307 ms
56,052 KB
testcase_27 AC 313 ms
54,476 KB
testcase_28 AC 663 ms
100,520 KB
testcase_29 AC 2 ms
4,376 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 1 ms
4,376 KB
testcase_34 AC 3 ms
4,376 KB
testcase_35 AC 2 ms
4,376 KB
testcase_36 AC 4 ms
4,380 KB
testcase_37 AC 5 ms
4,376 KB
testcase_38 AC 59 ms
14,032 KB
testcase_39 AC 96 ms
19,976 KB
testcase_40 AC 294 ms
51,040 KB
testcase_41 AC 174 ms
32,464 KB
testcase_42 AC 71 ms
15,624 KB
testcase_43 AC 50 ms
15,472 KB
testcase_44 AC 427 ms
100,996 KB
testcase_45 AC 39 ms
10,204 KB
testcase_46 AC 66 ms
21,904 KB
testcase_47 AC 580 ms
97,764 KB
testcase_48 AC 213 ms
59,676 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = (int)1e9;

ll N,M,W,H;
int combination_mod(int n, int m, int s=0){
    static vector<vector<int> > c;
    if(n<0||m<0||n<m)return 0;
    m=min(m,n-m);
    if((int)c.size()<=n)c.resize(n+1);
    if((int)c[n].size()==0) c[n].resize(n/2+1);
    if(c[n][m]!=0) return c[n][m];
    int res;
    if(n==0||m==0)res=1; else if(m==1)res=n;
    else res=(combination_mod(n-1,m,s+1)+combination_mod(n-1,m-1,s+1))%MOD;
    return(c[n][m]=res);
}

int main(){
    cin >> N >> M;
    N -= N/1000/M*1000*M;
    N = N/1000;

    cout << combination_mod(M,N) << endl;
}
0