結果

問題 No.129 お年玉(2)
ユーザー tetsuzuki1115tetsuzuki1115
提出日時 2018-10-13 18:38:36
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 585 ms / 5,000 ms
コード長 752 bytes
コンパイル時間 691 ms
コンパイル使用メモリ 90,392 KB
実行使用メモリ 165,844 KB
最終ジャッジ日時 2023-08-18 18:11:17
合計ジャッジ時間 12,507 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 31 ms
18,668 KB
testcase_01 AC 44 ms
43,816 KB
testcase_02 AC 2 ms
4,376 KB
testcase_03 AC 1 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 153 ms
67,844 KB
testcase_06 AC 359 ms
113,680 KB
testcase_07 AC 474 ms
142,340 KB
testcase_08 AC 135 ms
67,780 KB
testcase_09 AC 438 ms
133,272 KB
testcase_10 AC 475 ms
146,416 KB
testcase_11 AC 291 ms
93,344 KB
testcase_12 AC 109 ms
61,156 KB
testcase_13 AC 82 ms
54,884 KB
testcase_14 AC 416 ms
121,420 KB
testcase_15 AC 329 ms
101,380 KB
testcase_16 AC 338 ms
103,300 KB
testcase_17 AC 456 ms
137,120 KB
testcase_18 AC 503 ms
133,312 KB
testcase_19 AC 270 ms
103,136 KB
testcase_20 AC 440 ms
125,776 KB
testcase_21 AC 573 ms
165,844 KB
testcase_22 AC 337 ms
103,320 KB
testcase_23 AC 526 ms
151,712 KB
testcase_24 AC 144 ms
73,348 KB
testcase_25 AC 278 ms
88,456 KB
testcase_26 AC 283 ms
97,600 KB
testcase_27 AC 292 ms
97,920 KB
testcase_28 AC 585 ms
158,384 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 1 ms
4,376 KB
testcase_31 AC 1 ms
4,376 KB
testcase_32 AC 2 ms
4,376 KB
testcase_33 AC 2 ms
4,380 KB
testcase_34 AC 4 ms
5,276 KB
testcase_35 AC 6 ms
6,512 KB
testcase_36 AC 7 ms
7,264 KB
testcase_37 AC 7 ms
7,880 KB
testcase_38 AC 62 ms
29,108 KB
testcase_39 AC 94 ms
40,788 KB
testcase_40 AC 282 ms
92,708 KB
testcase_41 AC 171 ms
61,764 KB
testcase_42 AC 73 ms
33,116 KB
testcase_43 AC 46 ms
27,348 KB
testcase_44 AC 343 ms
129,840 KB
testcase_45 AC 40 ms
22,008 KB
testcase_46 AC 57 ms
33,788 KB
testcase_47 AC 514 ms
159,132 KB
testcase_48 AC 174 ms
76,980 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <math.h>
#include <cmath>
#include <limits.h>
#include <map>
#include <unordered_map>
#include <set>
#include <queue>
#include <algorithm>
#include <functional>
#include <stdio.h>
using namespace std;

long long MOD = 1000000007;

long long C[10001][10001];

long long func( int n, int r ) {


    if ( n/2 < r ) { r = n-r; }
    if ( r == 0 ) { return 1; }
    if ( C[n][r] > 0 ) { return C[n][r]; }

    C[n][r] = ( func( n-1, r ) + func( n-1, r-1 ) ) % ( (long long)1e9 );

    return C[n][r];
}


int main() {
    
    long long N,M;
    cin >> N >> M;

    int a = (N/1000)%M;
    
    long long ans = func( M, a );

    cout << ans << endl;
    

    return 0;
}
0