結果
| 問題 |
No.2872 Depth of the Parentheses
|
| コンテスト | |
| ユーザー |
nonon
|
| 提出日時 | 2024-09-06 21:46:09 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 712 bytes |
| コンパイル時間 | 1,906 ms |
| コンパイル使用メモリ | 197,544 KB |
| 最終ジャッジ日時 | 2025-02-24 04:11:33 |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 20 TLE * 1 -- * 4 |
ソースコード
#include<bits/stdc++.h>
#include<atcoder/modint>
using namespace std;
using mint=atcoder::modint998244353;
int main()
{
ios::sync_with_stdio(false);
cin.tie(nullptr);
int x,K;
cin>>x>>K;
vector<int>P(2*K,1);
for(int i=0;i<K;i++)P[i]=-1;
mint p=mint(x).pow(K)*mint(100-x).pow(K)/mint(100).pow(2*K);
mint ans=0;
do
{
auto f=[&]()->mint
{
int depth=0,S=0;
for(int i=0;i<2*K;i++)
{
S+=P[i];
if(S<0)return 0;
depth=max(depth,S);
}
return depth;
};
ans+=f()*p;
}while(next_permutation(P.begin(),P.end()));
cout<<ans.val()<<endl;
}
nonon