結果

問題 No.2383 Naphthol
ユーザー 👑 獅子座じゃない人獅子座じゃない人
提出日時 2023-07-14 23:18:25
言語 C++14
(gcc 12.3.0 + boost 1.83.0)
結果
WA  
実行時間 -
コード長 841 bytes
コンパイル時間 3,839 ms
コンパイル使用メモリ 230,704 KB
実行使用メモリ 5,632 KB
最終ジャッジ日時 2024-09-16 08:27:43
合計ジャッジ時間 4,189 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
5,248 KB
testcase_01 AC 2 ms
5,376 KB
testcase_02 AC 5 ms
5,376 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 WA -
testcase_09 AC 28 ms
5,632 KB
testcase_10 AC 28 ms
5,632 KB
testcase_11 AC 27 ms
5,504 KB
testcase_12 WA -
testcase_13 WA -
testcase_14 AC 20 ms
5,376 KB
testcase_15 AC 15 ms
5,376 KB
testcase_16 AC 23 ms
5,376 KB
testcase_17 AC 3 ms
5,376 KB
testcase_18 AC 23 ms
5,376 KB
testcase_19 AC 23 ms
5,376 KB
testcase_20 AC 28 ms
5,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
using namespace std;

#include <atcoder/all>
using namespace atcoder;
using mint=modint998244353;

int main(void) {
    int n,k;
    cin >> n >> k;
    vector<mint> inv(2*n+5,1);
    vector<mint> fact(2*n+5,1);
    vector<mint> finv(2*n+5,1);
    for(int i=2;i<=2*n+4;++i){
        inv[i]=mint(i).inv();
        fact[i]=fact[i-1]*i;
        finv[i]=finv[i-1]*inv[i];
    }
    mint ans=fact[2*n+4]*finv[k]*finv[2*n+4-k];
    if(n%2==0){
        if(k%2==0){
            ans+=fact[n+2]*finv[k/2]*finv[n+2-k/2]*3;
        }
    } else {
        if(k%2==0){
            ans+=fact[n+2]*finv[k/2]*finv[n+2-k/2]*2;
            ans+=fact[n+1]*finv[k/2]*finv[n+1-k/2]*2;
        } else {
            ans+=fact[n+1]*finv[(k-1)/2]*finv[n+1-(k-1)/2]*2;
        }
    }
    ans/=4;
    cout << ans.val() << endl;
    return 0;
}
0