結果

問題 No.2033 Chromatic Duel
ユーザー JashinchanJashinchan
提出日時 2022-08-24 11:02:45
言語 C
(gcc 12.3.0)
結果
WA  
実行時間 -
コード長 1,733 bytes
コンパイル時間 425 ms
コンパイル使用メモリ 32,256 KB
実行使用メモリ 12,844 KB
最終ジャッジ日時 2024-04-20 01:58:09
合計ジャッジ時間 2,100 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 10 ms
12,732 KB
testcase_01 WA -
testcase_02 AC 11 ms
12,736 KB
testcase_03 AC 10 ms
12,788 KB
testcase_04 AC 10 ms
12,804 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 10 ms
12,808 KB
testcase_10 WA -
testcase_11 AC 10 ms
12,748 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 10 ms
12,748 KB
testcase_17 AC 10 ms
12,724 KB
testcase_18 WA -
testcase_19 AC 9 ms
12,720 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 AC 10 ms
12,748 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 9 ms
12,736 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 WA -
testcase_32 AC 9 ms
12,740 KB
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 AC 11 ms
12,764 KB
testcase_39 WA -
testcase_40 AC 9 ms
12,724 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <stdio.h>

const long long mod = 998244353LL;
long long fact_table[700000];
long long invfact_table[700000];
long long pow_mod(long long a, long long k, long long m)
{
    long long ret = 1LL;
    while (k > 0)
    {
        if (k & 1)
            ret = (long long)((__int128_t)ret * a % m);
        a = (long long)((__int128_t)a * a % m);
        k >>= 1;
    }
    return ret;
}
void init_table(void)
{
    fact_table[0] = 1;
    for (int i = 1; i < 700000; ++i)
        fact_table[i] = fact_table[i - 1] * i % mod;
    invfact_table[699999] = pow_mod(fact_table[699999], mod - 2, mod);
    for (int i = 699998; i >= 0; --i)
        invfact_table[i] = invfact_table[i + 1] * (i + 1) % mod;
}
long long nCr_mod(long long n, long long r, long long m)
{
    if (r == 0)
        return 1;
    if (n < 0 || r < 0)
        return 0;
    if (n < r)
        return 0;
    return fact_table[n] * invfact_table[r] % m * invfact_table[n - r] % m;
}

int main(void)
{
    init_table();

    long long n, b, w;
    scanf("%lld %lld %lld", &n, &b, &w);
    long long k = n - b;
    long long ans = 0LL;

    for (long long i = 0; i < 3; ++i)
    {
        if (k < i)
            continue;
        long long c = k - i - w;
        if (2 * (b - 1) < c)
            continue;
        for (long long j = 0; j < b; ++j)
        {
            if (j * 2 > c)
                continue;
            long long t = nCr_mod(b - 1 - j, c - j * 2, mod) * nCr_mod(b - 1, j, mod) % mod;
            if (j == 1)
                ans = (ans + (t * nCr_mod(i + j + w - 1, w, mod) % mod) * 2) % mod;
            else
                ans = (ans + (t * nCr_mod(i + j + w - 1, w, mod) % mod)) % mod;
        }
    }

    printf("%lld\n", ans);
    return 0;
}
0