結果

問題 No.129 お年玉(2)
ユーザー commycommy
提出日時 2020-04-11 02:10:09
言語 C++17
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 1,480 ms / 5,000 ms
コード長 1,720 bytes
コンパイル時間 537 ms
コンパイル使用メモリ 76,256 KB
実行使用メモリ 327,136 KB
最終ジャッジ日時 2023-10-14 13:42:51
合計ジャッジ時間 21,125 ms
ジャッジサーバーID
(参考情報)
judge13 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
94,088 KB
testcase_01 AC 85 ms
155,452 KB
testcase_02 AC 1 ms
4,352 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 200 ms
186,432 KB
testcase_06 AC 874 ms
290,500 KB
testcase_07 AC 855 ms
301,332 KB
testcase_08 AC 163 ms
245,752 KB
testcase_09 AC 940 ms
284,928 KB
testcase_10 AC 736 ms
295,620 KB
testcase_11 AC 553 ms
256,424 KB
testcase_12 AC 253 ms
250,740 KB
testcase_13 AC 201 ms
249,920 KB
testcase_14 AC 906 ms
280,652 KB
testcase_15 AC 713 ms
262,468 KB
testcase_16 AC 781 ms
274,456 KB
testcase_17 AC 924 ms
287,252 KB
testcase_18 AC 656 ms
284,356 KB
testcase_19 AC 302 ms
271,280 KB
testcase_20 AC 992 ms
295,088 KB
testcase_21 AC 1,186 ms
313,744 KB
testcase_22 AC 532 ms
262,440 KB
testcase_23 AC 873 ms
301,636 KB
testcase_24 AC 155 ms
260,904 KB
testcase_25 AC 578 ms
259,628 KB
testcase_26 AC 361 ms
257,688 KB
testcase_27 AC 390 ms
256,764 KB
testcase_28 AC 1,480 ms
327,136 KB
testcase_29 AC 1 ms
4,352 KB
testcase_30 AC 1 ms
4,348 KB
testcase_31 AC 1 ms
4,348 KB
testcase_32 AC 1 ms
4,348 KB
testcase_33 AC 1 ms
4,352 KB
testcase_34 AC 7 ms
21,892 KB
testcase_35 AC 9 ms
33,000 KB
testcase_36 AC 12 ms
35,556 KB
testcase_37 AC 12 ms
40,132 KB
testcase_38 AC 114 ms
146,248 KB
testcase_39 AC 163 ms
181,236 KB
testcase_40 AC 553 ms
253,548 KB
testcase_41 AC 272 ms
237,504 KB
testcase_42 AC 107 ms
155,512 KB
testcase_43 AC 89 ms
152,080 KB
testcase_44 AC 429 ms
290,140 KB
testcase_45 AC 65 ms
113,604 KB
testcase_46 AC 125 ms
190,760 KB
testcase_47 AC 721 ms
304,916 KB
testcase_48 AC 201 ms
253,732 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <numeric>
#include <utility>
#include <tuple>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
using namespace std;
using ll = long long int;
using P = pair<int, int>;

// clang-format off
#ifdef _DEBUG_
#define dump(...) do{ cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = "; PPPPP(__VA_ARGS__); cerr << endl; } while(false)
template<typename T> void PPPPP(T t) { cerr << t; }
template<typename T, typename... S> void PPPPP(T t, S... s) { cerr << t << ", "; PPPPP(s...); }
#else
#define dump(...) do{ } while(false)
#endif
template<typename T> vector<T> make_v(size_t a, T b) { return vector<T>(a, b); }
template<typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v(ts...))>(a, make_v(ts...)); }
template<typename T> bool chmin(T &a, T b) { if (a > b) {a = b; return true; } return false; }
template<typename T> bool chmax(T &a, T b) { if (a < b) {a = b; return true; } return false; }
template<typename T> void print(T a) { cout << a << endl; }
template<typename T, typename... Ts> void print(T a, Ts... ts) { cout << a << ' '; print(ts...); }
template<typename T> istream &operator,(istream &in, T &t) { return in >> t; }
// clang-format on

const int SZ = 10010;
const int MOD = 1000000000;
bool used[SZ][SZ];
int comb[SZ][SZ];

int nCr(int n, int r) {
    if (r == 0 || n == r) return 1;
    if (used[n][r]) return comb[n][r];
    used[n][r] = true;
    return comb[n][r] = (nCr(n - 1, r - 1) + nCr(n - 1, r)) % MOD;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    ll n, m;
    cin, n, m;
    n /= 1000;
    n %= m;
    cout << nCr(m, n) << endl;
    return 0;
}
0