結果
| 問題 |
No.2530 Yellow Cards
|
| コンテスト | |
| ユーザー |
momoyuu
|
| 提出日時 | 2023-11-05 11:06:13 |
| 言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
TLE
|
| 実行時間 | - |
| コード長 | 861 bytes |
| コンパイル時間 | 3,096 ms |
| コンパイル使用メモリ | 253,340 KB |
| 実行使用メモリ | 205,984 KB |
| 最終ジャッジ日時 | 2024-09-25 22:23:39 |
| 合計ジャッジ時間 | 6,545 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 3 TLE * 1 -- * 13 |
ソースコード
#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;
}
momoyuu