結果

問題 No.129 お年玉(2)
ユーザー tetsuzuki1115tetsuzuki1115
提出日時 2018-10-11 02:08:43
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
MLE  
実行時間 -
コード長 797 bytes
コンパイル時間 894 ms
コンパイル使用メモリ 96,888 KB
実行使用メモリ 785,536 KB
最終ジャッジ日時 2024-10-12 17:31:07
合計ジャッジ時間 40,909 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample MLE * 3
other MLE * 46
権限があれば一括ダウンロードができます

ソースコード

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;

vector< vector<long long> > C( 10001, vector<long long>( 10001, 0 ) );


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