結果
問題 | No.2872 Depth of the Parentheses |
ユーザー |
![]() |
提出日時 | 2024-09-06 21:32:49 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 2 ms / 2,000 ms |
コード長 | 850 bytes |
コンパイル時間 | 4,025 ms |
コンパイル使用メモリ | 256,328 KB |
最終ジャッジ日時 | 2025-02-24 04:02:11 |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 WA * 5 |
ソースコード
#include <stdio.h>#include <bits/stdc++.h>#include <atcoder/all>using namespace atcoder;using mint = modint998244353;using namespace std;#define rep(i,n) for (int i = 0; i < (n); ++i)#define Inf32 1000000001#define Inf64 1000000000000000001int main(){mint p;int K;{int x;cin>>x;p = x;p /= 100;}cin>>K;if(K>10)return 0;vector dp(K+1,vector<mint>(K+1,0));dp[0][0] = 1;rep(i,K*2){vector ndp(K+1,vector<mint>(K+1,0));rep(j,K+1){rep(k,K+1){{mint nv = dp[j][k] * p;int nj = j+1;int nk = max(k,nj);if(nj<=K)ndp[nj][nk] += nv;}{mint nv = dp[j][k] * (1-p);int nj = j-1;int nk = max(k,nj);if(nj>=0)ndp[nj][nk] += nv;}}}swap(dp,ndp);}mint ans = 0;rep(i,K+1){ans += dp[0][i] * i;}cout<<ans.val()<<endl;return 0;}