結果

問題 No.129 お年玉(2)
ユーザー mamekin
提出日時 2015-01-22 22:25:58
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 86 ms / 5,000 ms
コード長 901 bytes
コンパイル時間 2,482 ms
コンパイル使用メモリ 91,768 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-11-27 23:35:03
合計ジャッジ時間 5,469 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 46
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <cstdio>
#include <iostream>
#include <sstream>
#include <fstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <limits>
#include <climits>
#include <cfloat>
#include <functional>
using namespace std;

const int MOD = 1000000000;

void combination(int n, vector<long long>& comb)
{
    comb.assign(2, 0);
    comb[0] = 1;
    for(int i=1; i<=n; ++i){
        vector<long long> tmp(i+2, 0);
        tmp[0] = 1;
        for(int j=1; j<=i; ++j){
            tmp[j] = comb[j-1] + comb[j];
            tmp[j] %= MOD;
        }
        comb.swap(tmp);
    }
}

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

    vector<long long> comb;
    combination(m, comb);
    cout << comb[n / 1000 % m] << endl;

    return 0;
}
0