結果
問題 |
No.2872 Depth of the Parentheses
|
ユーザー |
![]() |
提出日時 | 2024-09-06 22:19:13 |
言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
結果 |
WA
|
実行時間 | - |
コード長 | 1,432 bytes |
コンパイル時間 | 1,939 ms |
コンパイル使用メモリ | 193,808 KB |
最終ジャッジ日時 | 2025-02-24 04:30:37 |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 14 WA * 11 |
ソースコード
#include <bits/stdc++.h> using namespace std; using ll = long long; #define ALL(v) v.begin(),v.end() #define dbg(x) cerr << #x << ": " << (x) << endl; template<class F, class S> ostream& operator<<(ostream& os, pair<F,S>& p) { os << '(' << p.first << ',' << p.second << ')'; return os; } template<class Iter> void print(Iter beg, Iter end) { for (Iter itr = beg; itr != end; ++itr) { cerr << *itr << ' '; } cerr << '\n'; } ll x,k; ll mod = 998244353; ll modpow(ll x, ll n, ll mod) { x %= mod; ll res = 1; while (n > 0) { if (n&1) res = res*x%mod; x = x*x%mod; n >>= 1; } return res; } int main() { cin >> x >> k; if (x > 100 || k > 10) return 0; x = x * modpow(100, mod-2, mod) % mod; k *= 2; ll ans = 0; for (int mask = 0; mask < 1<<k; ++mask) { ll p = 1; int ma = 0; int now = 0; bool ok = true; for (int i = 0; i < k; ++i) { if (mask >> i & 1) { ++now; p = p * x % mod; } else { --now; p = p * (1-x) % mod; } if (now < 0) { ok = false; break; } ma = max(ma, now); } ok = (ok && (now == 0)); if (ok) { ans += p * ma % mod; ans %= mod; } } cout << ans << '\n'; }