結果

問題 No.129 お年玉(2)
ユーザー 🍮かんプリン
提出日時 2019-04-30 01:43:13
言語 C++11(廃止可能性あり)
(gcc 13.3.0)
結果
AC  
実行時間 368 ms / 5,000 ms
コード長 980 bytes
コンパイル時間 1,677 ms
コンパイル使用メモリ 76,700 KB
実行使用メモリ 394,240 KB
最終ジャッジ日時 2024-11-28 01:20:35
合計ジャッジ時間 11,220 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 46
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>
#include <queue>
#include <stack>
#include <math.h>
#include <set>
#include <cstdio>
#define ALL(obj) (obj).begin(),(obj).end()
#define RALL(obj) (obj).rbegin(),(obj).rend()
#define P pair<int, int>

#define MOD 1000000007
#define INF 1012345678
#define NINF (-2147483647-1)
#define LLINF 9223372036854775807
using ll = long long;
using namespace std;

// combination
int comb(int n, int r) {
    vector<vector<int>> v(n + 1, vector<int>(n + 1, 0));
    for (int i = 0; i < v.size(); i++) {
        v[i][0] = 1;
        v[i][i] = 1;
    }
    for (int j = 1; j < v.size(); j++) {
        for (int k = 1; k < j; k++) {
            v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]) % 1000000000;
        }
    }
    return v[n][r];
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N,M;
    cin >> N >> M;
    cout << comb(M, N / 1000 % M) << endl;
    getchar(); getchar();
}
0