結果

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

ソースコード

diff #

#include<bits/stdc++.h>
#include<atcoder/modint>
using namespace atcoder;
using mint=modint998244353;
using namespace std;
using ll=long long;


int main() {
    ll X,K;
    cin>>X>>K;
    if(K>10)return 0;
    mint an=0;
    mint iv=mint(100).inv();
    for(int bit=0;bit<(1<<(2*K));bit++){
        ll mx=0,k=0;
        bool OK=1;
        mint res=1;
        for(int i=0;i<2*K;i++){
            if(bit&(1<<i)){
                k++;
                res*=iv*X;
            }
            else{
                k--;
                res*=iv*(100-X);
            }
            mx=max(mx,k);
            if(k<0)OK=0;
        }
        if(k!=0)OK=0;
        if(OK)an+=res*mx;
    }    
    cout<<an.val()<<endl;
}
0