結果

問題 No.2472 Tea time in the grand garden
ユーザー だれだれ
提出日時 2023-08-16 21:57:00
言語 C++17
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 1,058 bytes
コンパイル時間 769 ms
コンパイル使用メモリ 82,764 KB
実行使用メモリ 11,336 KB
最終ジャッジ日時 2024-05-04 05:18:09
合計ジャッジ時間 2,448 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 11 ms
11,336 KB
testcase_01 AC 12 ms
11,332 KB
testcase_02 AC 11 ms
11,208 KB
testcase_03 AC 15 ms
11,332 KB
testcase_04 AC 12 ms
11,332 KB
testcase_05 AC 12 ms
11,200 KB
testcase_06 AC 12 ms
11,208 KB
testcase_07 AC 12 ms
11,208 KB
testcase_08 AC 11 ms
11,204 KB
testcase_09 AC 11 ms
11,208 KB
testcase_10 AC 12 ms
11,332 KB
testcase_11 AC 12 ms
11,336 KB
testcase_12 AC 11 ms
11,204 KB
testcase_13 AC 13 ms
11,208 KB
testcase_14 AC 13 ms
11,208 KB
testcase_15 AC 13 ms
11,204 KB
testcase_16 AC 12 ms
11,208 KB
testcase_17 WA -
testcase_18 AC 12 ms
11,204 KB
testcase_19 AC 12 ms
11,204 KB
testcase_20 WA -
testcase_21 WA -
testcase_22 AC 12 ms
11,204 KB
testcase_23 WA -
testcase_24 WA -
testcase_25 AC 13 ms
11,200 KB
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 AC 13 ms
11,336 KB
testcase_31 AC 14 ms
11,212 KB
testcase_32 WA -
testcase_33 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <atcoder/modint>
#include <cmath>
#include <iostream>
using namespace std;

using mint = atcoder::modint998244353;
using i64 = long long;

mint fact[1000010];
mint ifact[1000010];

mint binom(int n, int r) {
    if (n < 0 || r < 0 || n < r) return 0;
    return fact[n] * ifact[r] * ifact[n - r];
}

void solve() {
    int n, k;
    cin >> n >> k;
    if (k == 0) {
        cout << 1 << "\n";
        return;
    }
    mint invk = mint(k).inv();
    mint ans = 0;
    for (int p = 1; p <= k; p += 2) {
        int l = (p + 1) / 2;
        mint tmp = binom(2 * k + n - p, n - p);
        tmp *= binom(k, l) * binom(k, l - 1) * invk;
        ans += tmp;
    }
    cout << ans.val() << "\n";
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int t;
    // cin >> t;
    t = 1;
    fact[0] = 1;
    for (int i = 1; i <= 1000000; i++) {
        fact[i] = fact[i - 1] * i;
    }
    ifact[1000000] = fact[1000000].inv();
    for (int i = 1000000; i > 0; i--) {
        ifact[i - 1] = ifact[i] * i;
    }
    while (t--) solve();
}
0