結果

問題 No.129 お年玉(2)
ユーザー face4
提出日時 2018-08-27 14:31:53
言語 C++14
(gcc 13.3.0 + boost 1.87.0)
結果
WA  
実行時間 -
コード長 772 bytes
コンパイル時間 689 ms
コンパイル使用メモリ 73,172 KB
実行使用メモリ 785,152 KB
最終ジャッジ日時 2024-07-01 04:08:02
合計ジャッジ時間 18,327 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5 WA * 24 MLE * 17
権限があれば一括ダウンロードができます

ソースコード

diff #

#include<iostream>
#include<vector>
using namespace std;

typedef long long ll;

struct Combination{
    int n;
    vector<vector<ll>> dp;

    Combination(int i){
        n = i;
        dp = vector<vector<ll>>(n+1, vector<ll>(n+1, 0));
        constructTriangle();
    }

    void constructTriangle(){
        dp[0][0] = 1;
        for(int i = 1; i <= n; i++){
            for(int j = 0; j <= n; j++){
                dp[i][j] = dp[i-1][j];
                if(j)   dp[i][j] += dp[i-1][j-1];
            }
        }
    }

    // return aCb
    ll getCombination(int a, int b){
        return dp[a][b];
    }
};

int main(){
    ll n, m;
    cin >> n >> m;

    n /= 1000;

    Combination c(m);

    cout << c.getCombination(m, n%m) % 1000000000 << endl;

    return 0;
}
0