結果
問題 | No.2530 Yellow Cards |
ユーザー |
![]() |
提出日時 | 2023-10-24 22:30:38 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 334 ms / 2,000 ms |
コード長 | 547 bytes |
コンパイル時間 | 1,925 ms |
コンパイル使用メモリ | 200,048 KB |
最終ジャッジ日時 | 2025-02-17 13:31:05 |
ジャッジサーバーID (参考情報) |
judge5 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 17 |
ソースコード
#include<bits/stdc++.h> using namespace std; #include<atcoder/modint> typedef atcoder::modint998244353 mint; int main(){ int n, k; cin >> n >> k; mint ans = n; mint ninv = mint(n).inv(); vector dp(k+1, vector<mint>(n+1)); dp[0][0] = 1; for (int i=0; i<k; i++){ for (int j=0; j<=n; j++){ // select reach if (j > 0){ dp[i+1][j-1] += mint(j) * ninv * dp[i][j]; ans += mint(j) * ninv * dp[i][j]; } // select other if (j < n){ dp[i+1][j+1] += mint(n-j) * ninv * dp[i][j]; } } } cout << ans.val() << '\n'; }