結果

問題 No.741 AscNumber(Easy)
ユーザー PachicobuePachicobue
提出日時 2018-10-05 21:29:14
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 55 ms / 2,000 ms
コード長 1,436 bytes
コンパイル時間 2,404 ms
コンパイル使用メモリ 200,628 KB
実行使用メモリ 26,552 KB
最終ジャッジ日時 2023-08-02 16:52:48
合計ジャッジ時間 4,773 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,376 KB
testcase_01 AC 2 ms
4,376 KB
testcase_02 AC 2 ms
4,380 KB
testcase_03 AC 2 ms
4,376 KB
testcase_04 AC 2 ms
4,376 KB
testcase_05 AC 1 ms
4,376 KB
testcase_06 AC 1 ms
4,380 KB
testcase_07 AC 1 ms
4,380 KB
testcase_08 AC 1 ms
4,376 KB
testcase_09 AC 2 ms
4,380 KB
testcase_10 AC 2 ms
4,380 KB
testcase_11 AC 1 ms
4,376 KB
testcase_12 AC 2 ms
4,376 KB
testcase_13 AC 2 ms
4,376 KB
testcase_14 AC 2 ms
4,380 KB
testcase_15 AC 1 ms
4,376 KB
testcase_16 AC 2 ms
4,380 KB
testcase_17 AC 2 ms
4,380 KB
testcase_18 AC 1 ms
4,380 KB
testcase_19 AC 1 ms
4,380 KB
testcase_20 AC 1 ms
4,376 KB
testcase_21 AC 1 ms
4,376 KB
testcase_22 AC 2 ms
4,376 KB
testcase_23 AC 2 ms
4,380 KB
testcase_24 AC 1 ms
4,380 KB
testcase_25 AC 2 ms
4,380 KB
testcase_26 AC 2 ms
4,384 KB
testcase_27 AC 2 ms
4,380 KB
testcase_28 AC 2 ms
4,376 KB
testcase_29 AC 1 ms
4,380 KB
testcase_30 AC 2 ms
4,376 KB
testcase_31 AC 1 ms
4,380 KB
testcase_32 AC 1 ms
4,376 KB
testcase_33 AC 2 ms
4,376 KB
testcase_34 AC 1 ms
4,376 KB
testcase_35 AC 49 ms
25,556 KB
testcase_36 AC 20 ms
12,708 KB
testcase_37 AC 23 ms
14,492 KB
testcase_38 AC 23 ms
14,460 KB
testcase_39 AC 20 ms
12,700 KB
testcase_40 AC 27 ms
16,000 KB
testcase_41 AC 41 ms
23,412 KB
testcase_42 AC 21 ms
13,664 KB
testcase_43 AC 17 ms
10,908 KB
testcase_44 AC 33 ms
19,004 KB
testcase_45 AC 37 ms
20,152 KB
testcase_46 AC 45 ms
24,484 KB
testcase_47 AC 9 ms
6,736 KB
testcase_48 AC 44 ms
24,456 KB
testcase_49 AC 34 ms
20,852 KB
testcase_50 AC 6 ms
5,408 KB
testcase_51 AC 17 ms
11,248 KB
testcase_52 AC 47 ms
26,516 KB
testcase_53 AC 55 ms
26,552 KB
testcase_54 AC 48 ms
26,352 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#define show(x) std::cerr << #x << " = " << x << std::endl
using ll = long long;
using ull = unsigned long long;
using ld = long double;
constexpr ll MOD = 1000000007LL;
template <typename T>
constexpr T INF = std::numeric_limits<T>::max() / 10;
std::mt19937 mt{std::random_device{}()};
template <ll mod = MOD>
class ModCombination
{
public:
    ModCombination(const std::size_t n) : fact(n + 1, 1), inv(n + 1, 1), inv_fact(n + 1, 1)
    {
        for (ll i = 2; i <= (ll)n; i++) { fact[i] = (fact[i - 1] * i) % mod, inv[i] = ((mod - (mod / i)) * inv[mod % i]) % mod, inv_fact[i] = (inv_fact[i - 1] * inv[i]) % mod; }
    }
    ll factorial(const std::size_t n) const { return fact[n]; }
    ll inverse(const std::size_t n) const { return inv[n]; }
    ll inverseFactorial(const std::size_t n) const { return inv_fact[n]; }
    ll permutation(const std::size_t n, const std::size_t k) const { return (fact[n] * inv_fact[n - k]) % mod; }
    ll combination(const std::size_t n, const std::size_t k) const { return (((fact[n] * inv_fact[k]) % mod) * inv_fact[n - k]) % mod; }
    ll homogenious(const std::size_t n, const std::size_t k) const { return (n == 0 and k == 0 ? 1 : combination(n + k - 1, k)); }

private:
    std::vector<ll> fact, inv, inv_fact;
};

int main()
{
    int N;
    std::cin >> N;
    ModCombination<> mod(N + 10);
    std::cout << mod.combination(N + 9, 9) << std::endl;

    return 0;
}
0