結果
問題 | No.129 お年玉(2) |
ユーザー | commy |
提出日時 | 2020-04-11 02:05:17 |
言語 | C++17 (gcc 12.3.0 + boost 1.83.0) |
結果 |
MLE
|
実行時間 | - |
コード長 | 3,494 bytes |
コンパイル時間 | 987 ms |
コンパイル使用メモリ | 99,116 KB |
実行使用メモリ | 798,592 KB |
最終ジャッジ日時 | 2024-09-16 08:10:40 |
合計ジャッジ時間 | 30,513 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 25 ms
15,232 KB |
testcase_01 | MLE | - |
testcase_02 | AC | 20 ms
6,944 KB |
testcase_03 | AC | 2 ms
6,940 KB |
testcase_04 | AC | 3 ms
6,944 KB |
testcase_05 | AC | 528 ms
275,712 KB |
testcase_06 | AC | 868 ms
223,872 KB |
testcase_07 | AC | 1,411 ms
407,296 KB |
testcase_08 | AC | 574 ms
391,808 KB |
testcase_09 | AC | 762 ms
198,400 KB |
testcase_10 | AC | 1,401 ms
463,360 KB |
testcase_11 | AC | 831 ms
235,648 KB |
testcase_12 | AC | 79 ms
31,488 KB |
testcase_13 | AC | 56 ms
23,296 KB |
testcase_14 | AC | 901 ms
228,096 KB |
testcase_15 | AC | 723 ms
194,432 KB |
testcase_16 | AC | 1,033 ms
269,952 KB |
testcase_17 | AC | 580 ms
172,544 KB |
testcase_18 | AC | 1,261 ms
406,016 KB |
testcase_19 | MLE | - |
testcase_20 | AC | 1,332 ms
337,664 KB |
testcase_21 | AC | 811 ms
214,144 KB |
testcase_22 | AC | 902 ms
276,608 KB |
testcase_23 | AC | 1,512 ms
455,936 KB |
testcase_24 | MLE | - |
testcase_25 | AC | 780 ms
222,464 KB |
testcase_26 | AC | 826 ms
324,736 KB |
testcase_27 | AC | 803 ms
301,056 KB |
testcase_28 | AC | 1,562 ms
350,208 KB |
testcase_29 | AC | 3 ms
6,940 KB |
testcase_30 | AC | 3 ms
6,944 KB |
testcase_31 | AC | 2 ms
6,940 KB |
testcase_32 | AC | 2 ms
6,940 KB |
testcase_33 | AC | 3 ms
6,940 KB |
testcase_34 | AC | 3 ms
6,944 KB |
testcase_35 | AC | 3 ms
6,944 KB |
testcase_36 | AC | 5 ms
6,940 KB |
testcase_37 | AC | 5 ms
6,944 KB |
testcase_38 | AC | 75 ms
39,808 KB |
testcase_39 | AC | 87 ms
41,472 KB |
testcase_40 | AC | 315 ms
112,000 KB |
testcase_41 | AC | 395 ms
143,872 KB |
testcase_42 | AC | 124 ms
66,048 KB |
testcase_43 | AC | 36 ms
16,128 KB |
testcase_44 | MLE | - |
testcase_45 | AC | 54 ms
36,992 KB |
testcase_46 | AC | 44 ms
19,840 KB |
testcase_47 | MLE | - |
testcase_48 | AC | 661 ms
404,352 KB |
ソースコード
#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 template<ll MOD = 1000000007> class ModInt { ll n; ModInt constexpr inverse() const { return ModInt::pow(*this, MOD - 2); } public: ModInt() : n(0) {} ModInt(ll _n) : n(((_n % MOD) + MOD) % MOD) {} ModInt operator+=(const ModInt &m) { n += m.n; if (n >= MOD) n -= MOD; return *this; } ModInt operator-=(const ModInt &m) { n -= m.n; if (n < 0) n += MOD; return *this; } ModInt operator*=(const ModInt &m) { n *= m.n; if (n >= MOD) n %= MOD; return *this; } ModInt operator/=(const ModInt &m) { (*this) *= m.inverse(); return *this; } friend ModInt operator+(ModInt t, const ModInt &m) { return t += m; } friend ModInt operator-(ModInt t, const ModInt &m) { return t -= m; } friend ModInt operator*(ModInt t, const ModInt &m) { return t *= m; } friend ModInt operator/(ModInt t, const ModInt &m) { return t /= m; } ModInt operator=(const ll l) { n = l % MOD; if (n < 0) n += MOD; return *this; } friend ostream &operator<<(ostream &out, const ModInt &m) { out << m.n; return out; } friend istream &operator>>(istream &in, ModInt &m) { ll l; in >> l; m = l; return in; } static constexpr ModInt pow(const ModInt x, ll p) { ModInt<MOD> ans = 1; for (ModInt<MOD> m = x; p > 0; p /= 2, m *= m) { if (p % 2) ans *= m; } return ans; } }; using mint = ModInt<1000000000>; mint operator"" _m(unsigned long long m) { return mint(m); } #include <functional> int main() { cin.tie(nullptr); ios::sync_with_stdio(false); ll n, m; cin, n, m; n /= 1000; n %= m; auto used = make_v(m + 1, n + 1, false); auto comb = make_v(m + 1, n + 1, 0_m); function<mint(int, int)> nCr = [&](int n, int r) { if (r == 0 || n == r) return 1_m; 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); }; cout << nCr(m, n) << endl; return 0; }