結果
| 問題 |
No.2530 Yellow Cards
|
| コンテスト | |
| ユーザー |
momoyuu
|
| 提出日時 | 2023-11-05 11:06:57 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 509 ms / 2,000 ms |
| コード長 | 886 bytes |
| コンパイル時間 | 3,122 ms |
| コンパイル使用メモリ | 251,980 KB |
| 実行使用メモリ | 199,040 KB |
| 最終ジャッジ日時 | 2024-09-25 22:23:49 |
| 合計ジャッジ時間 | 8,831 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 17 |
ソースコード
#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;
mint invn = 1 / mint(n);
for(int i = 0;i<k;i++){
for(int j = 0;j<=n;j++){
mint ok = mint(j) * invn;
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;
}
momoyuu