結果

問題 No.2530 Yellow Cards
ユーザー momoyuumomoyuu
提出日時 2023-11-05 11:06:13
言語 C++23
(gcc 12.3.0 + boost 1.83.0)
結果
TLE  
実行時間 -
コード長 861 bytes
コンパイル時間 2,999 ms
コンパイル使用メモリ 253,052 KB
実行使用メモリ 203,456 KB
最終ジャッジ日時 2023-11-05 11:06:21
合計ジャッジ時間 7,155 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
8,696 KB
testcase_01 AC 2 ms
4,348 KB
testcase_02 AC 4 ms
4,348 KB
testcase_03 AC 6 ms
4,348 KB
testcase_04 AC 2 ms
4,348 KB
testcase_05 AC 4 ms
4,348 KB
testcase_06 AC 3 ms
4,348 KB
testcase_07 TLE -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
権限があれば一括ダウンロードができます

ソースコード

diff #

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


#include<atcoder/modint>
using mint = atcoder::modint998244353;


int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);

    int n,k;
    cin>>n>>k;
    vector<vector<mint>> dp1(k+1,vector<mint>(n+1,0)),dp2(k+1,vector<mint>(n+1,0));
    dp1[0][0] = 1;

    for(int i = 0;i<k;i++){
        for(int j = 0;j<=n;j++){
            mint ok = mint(j) / mint(n);
            if(j-1>=0){
                dp1[i+1][j-1] += dp1[i][j] * ok;
                dp2[i+1][j-1] += ok * (dp1[i][j]+dp2[i][j]);
            }
            mint no = 1 - ok;
            if(j+1<=n){
                dp1[i+1][j+1] += dp1[i][j] * no;
                dp2[i+1][j+1] += dp2[i][j] * no;
            }
        }
    }
    mint ans = n;
    for(int i = 0;i<=n;i++) ans += dp2[k][i];
    cout<<ans.val()<<endl;

}
0