結果

問題 No.2141 Enumeratest
ユーザー 👑 NachiaNachia
提出日時 2022-12-02 22:15:53
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
AC  
実行時間 25 ms / 2,000 ms
コード長 2,183 bytes
コンパイル時間 736 ms
コンパイル使用メモリ 82,144 KB
実行使用メモリ 18,868 KB
最終ジャッジ日時 2024-04-27 04:18:28
合計ジャッジ時間 1,951 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
6,816 KB
testcase_01 AC 2 ms
6,940 KB
testcase_02 AC 5 ms
6,944 KB
testcase_03 AC 13 ms
10,980 KB
testcase_04 AC 25 ms
18,868 KB
testcase_05 AC 16 ms
10,984 KB
testcase_06 AC 2 ms
6,940 KB
testcase_07 AC 3 ms
6,940 KB
testcase_08 AC 7 ms
6,944 KB
testcase_09 AC 4 ms
6,940 KB
testcase_10 AC 8 ms
7,680 KB
testcase_11 AC 12 ms
10,212 KB
testcase_12 AC 2 ms
6,940 KB
testcase_13 AC 4 ms
6,940 KB
testcase_14 AC 12 ms
10,176 KB
testcase_15 AC 8 ms
7,296 KB
testcase_16 AC 9 ms
8,268 KB
testcase_17 AC 17 ms
12,696 KB
testcase_18 AC 15 ms
11,732 KB
testcase_19 AC 22 ms
15,736 KB
testcase_20 AC 15 ms
11,944 KB
testcase_21 AC 18 ms
12,480 KB
testcase_22 AC 13 ms
9,724 KB
testcase_23 AC 9 ms
7,296 KB
testcase_24 AC 15 ms
12,112 KB
testcase_25 AC 5 ms
6,940 KB
testcase_26 AC 15 ms
10,456 KB
testcase_27 AC 16 ms
11,840 KB
testcase_28 AC 19 ms
12,988 KB
testcase_29 AC 12 ms
8,548 KB
testcase_30 AC 22 ms
15,648 KB
testcase_31 AC 16 ms
11,708 KB
testcase_32 AC 17 ms
13,604 KB
testcase_33 AC 14 ms
10,824 KB
testcase_34 AC 18 ms
13,680 KB
testcase_35 AC 2 ms
6,940 KB
testcase_36 AC 18 ms
12,928 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#line 1 "Main.cpp"
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <atcoder/modint.hpp>
#line 3 "nachia\\math\\combination.hpp"

namespace nachia{

template<class Modint>
class Comb{
private:
    std::vector<Modint> F;
    std::vector<Modint> iF;
public:
    void extend(int newN){
        int prevN = (int)F.size() - 1;
        if(prevN >= newN) return;
        F.resize(newN+1);
        iF.resize(newN+1);
        for(int i=prevN+1; i<=newN; i++) F[i] = F[i-1] * Modint::raw(i);
        iF[newN] = F[newN].inv();
        for(int i=newN; i>prevN; i--) iF[i-1] = iF[i] * Modint::raw(i);
    }
    Comb(int n = 1){
        F.assign(2, Modint(1));
        iF.assign(2, Modint(1));
        extend(n);
    }
    Modint factorial(int n) const { return F[n]; }
    Modint invFactorial(int n) const { return iF[n]; }
    Modint invOf(int n) const { return iF[n] * F[n-1]; }
    Modint comb(int n, int r) const {
        if(n < 0 || n < r || r < 0) return Modint(0);
        return F[n] * iF[r] * iF[n-r];
    }
    Modint invComb(int n, int r) const {
        if(n < 0 || n < r || r < 0) return Modint(0);
        return iF[n] * F[r] * F[n-r];
    }
    Modint perm(int n, int r) const {
        if(n < 0 || n < r || r < 0) return Modint(0);
        return F[n] * iF[n-r];
    }
    Modint invPerm(int n, int r) const {
        if(n < 0 || n < r || r < 0) return Modint(0);
        return iF[n] * F[n-r];
    }
    Modint operator()(int n, int r) const { return comb(n,r); }
};

} // namespace nachia
#line 8 "Main.cpp"

using namespace std;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;
#define rep(i,n) for(int i=0; i<(int)(n); i++)
const i64 INF = 1001001001001001001;

using Modint = atcoder::modint998244353;

int main(){
    int N, M; cin >> N >> M;
    auto C = nachia::Comb<Modint>(N+M);
    Modint ans = C.factorial(M);
    for(int i=0; i<N; i++) ans *= C.invFactorial((M+i)/N);
    cout << ans.val() << '\n';
    return 0;
}


struct ios_do_not_sync{
    ios_do_not_sync(){
        std::ios::sync_with_stdio(false);
        std::cin.tie(nullptr);
    }
} ios_do_not_sync_instance;


0