結果

問題 No.2872 Depth of the Parentheses
ユーザー t98slider
提出日時 2024-09-07 12:50:22
言語 C++17
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 28 ms / 2,000 ms
コード長 618 bytes
コンパイル時間 3,865 ms
コンパイル使用メモリ 251,196 KB
最終ジャッジ日時 2025-02-24 05:08:02
ジャッジサーバーID
(参考情報)
judge3 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 21 WA * 4
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using mint = atcoder::modint998244353;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int x, K;
    cin >> x >> K;
    const int r = 2 * K;
    mint coef = mint(x).pow(K) * mint(100 - x).pow(K) / mint(10000).pow(K), ans;
    for(int S = 0; S < (1 << r); S++){
        int sv = 0, mx = 0, mn = 0;
        for(int i = 0; i < r; i++){
            sv += (S >> i & 1 ? 1 : -1);
            mx = max(mx, sv);
            mn = min(mn, sv);
        }
        if(sv == 0 && mn == 0) ans += mx * coef;
    }
    cout << ans.val() << '\n';
}
0