結果

問題 No.1989 Pairing Multiset
ユーザー みここみここ
提出日時 2022-06-24 22:06:42
言語 C++14
(gcc 13.2.0 + boost 1.83.0)
結果
AC  
実行時間 306 ms / 2,000 ms
コード長 1,277 bytes
コンパイル時間 573 ms
コンパイル使用メモリ 69,108 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-26 05:18:30
合計ジャッジ時間 4,902 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 304 ms
5,248 KB
testcase_01 AC 300 ms
5,376 KB
testcase_02 AC 300 ms
5,376 KB
testcase_03 AC 306 ms
5,376 KB
testcase_04 AC 2 ms
5,376 KB
testcase_05 AC 306 ms
5,376 KB
testcase_06 AC 2 ms
5,376 KB
testcase_07 AC 2 ms
5,376 KB
testcase_08 AC 286 ms
5,376 KB
testcase_09 AC 13 ms
5,376 KB
testcase_10 AC 104 ms
5,376 KB
testcase_11 AC 190 ms
5,376 KB
testcase_12 AC 204 ms
5,376 KB
testcase_13 AC 292 ms
5,376 KB
testcase_14 AC 48 ms
5,376 KB
testcase_15 AC 42 ms
5,376 KB
testcase_16 AC 253 ms
5,376 KB
testcase_17 AC 23 ms
5,376 KB
testcase_18 AC 2 ms
5,376 KB
testcase_19 AC 39 ms
5,376 KB
testcase_20 AC 305 ms
5,376 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <vector>
using namespace std;
typedef long long ll;

const ll MOD = 998244353;

long long modpow(long long x, long long n)
{
    long long res = 1;
    long long mul = x;
    while (n)
    {
        if (n % 2)
            res = res * mul % MOD;
        mul = mul * mul % MOD;
        n /= 2;
    }
    return res;
}

struct Combination
{
    int maxn;
    std::vector<long long> fact;
    std::vector<long long> ifact;

    Combination(int maxn) : maxn(maxn)
    {
        fact.resize(maxn + 1);
        ifact.resize(maxn + 1);
        fact[0] = 1;
        for (int i = 1; i <= maxn; i++)
            fact[i] = fact[i - 1] * i % MOD;
        ifact[maxn] = modpow(fact[maxn], MOD - 2);
        for (int i = maxn - 1; i >= 0; i--)
            ifact[i] = ifact[i + 1] * (i + 1) % MOD;
    }

    long long com(int n, int k)
    {
        if (k > n || k < 0)
            return 0;
        return (fact[n] * ifact[k] % MOD) * ifact[n - k] % MOD;
    }
};

int main()
{
    ll n, m;
    cin >> n >> m;
    ll s = 1;
    for (int i = m + n * 2; i >= m; i--)
    {
        s = s * i % MOD;
    }
    for (int i = n * 2; i > 0; i--)
    {
        s = s * modpow(i, MOD - 2) % MOD;
    }
    cout << s * n % MOD * modpow(n * 2 + 1, MOD - 2) % MOD << endl;
}
0