結果
| 問題 |
No.2872 Depth of the Parentheses
|
| コンテスト | |
| ユーザー |
寝癖
|
| 提出日時 | 2024-07-14 14:10:08 |
| 言語 | C++14 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
AC
|
| 実行時間 | 27 ms / 2,000 ms |
| コード長 | 603 bytes |
| コンパイル時間 | 3,786 ms |
| コンパイル使用メモリ | 230,936 KB |
| 実行使用メモリ | 6,944 KB |
| 最終ジャッジ日時 | 2024-09-06 20:50:11 |
| 合計ジャッジ時間 | 4,420 ms |
|
ジャッジサーバーID (参考情報) |
judge3 / judge4 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 WA * 4 |
ソースコード
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using mint = modint998244353;
int depth(int bit, int K) {
int res = 0, d = 0;
for (int i = 0; i < 2*K; i++) {
if (bit>>i&1) d++;
else d--;
if (d < 0) return 0;
res = max(res, d);
}
if (d != 0) return 0;
return res;
}
int main() {
int x, K;
cin >> x >> K;
mint p = mint(x) / 100;
mint res = 0;
for (int bit = 0; bit < (1<<(2*K)); bit++) {
res += depth(bit, K);
}
res *= p.pow(K) * (1-p).pow(K);
cout << res.val() << endl;
}
寝癖