結果

問題 No.2872 Depth of the Parentheses
ユーザー 沙耶花沙耶花
提出日時 2024-09-06 21:32:49
言語 C++17(gcc12)
(gcc 12.3.0 + boost 1.87.0)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 850 bytes
コンパイル時間 4,704 ms
コンパイル使用メモリ 266,792 KB
実行使用メモリ 6,944 KB
最終ジャッジ日時 2024-09-06 21:32:55
合計ジャッジ時間 5,464 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 20 WA * 5
権限があれば一括ダウンロードができます

ソースコード

diff #

#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 1000000000000000001

int 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;
}
0