結果
問題 | No.2872 Depth of the Parentheses |
ユーザー | shobonvip |
提出日時 | 2024-09-06 22:52:38 |
言語 | C++17(gcc12) (gcc 12.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 24 ms / 2,000 ms |
コード長 | 1,474 bytes |
コンパイル時間 | 4,132 ms |
コンパイル使用メモリ | 263,912 KB |
実行使用メモリ | 6,944 KB |
最終ジャッジ日時 | 2024-09-06 22:53:50 |
合計ジャッジ時間 | 5,528 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 20 RE * 5 |
ソースコード
#include<bits/stdc++.h> using namespace std; //* ATCODER #include<atcoder/all> using namespace atcoder; typedef modint998244353 mint; //*/ /* BOOST MULTIPRECISION #include<boost/multiprecision/cpp_int.hpp> using namespace boost::multiprecision; //*/ typedef long long ll; #define rep(i, s, n) for (int i = (int)(s); i < (int)(n); i++) #define rrep(i, s, n) for (int i = (int)(n)-1; i >= (int)(s); i--) template <typename T> bool chmin(T &a, const T &b) { if (a <= b) return false; a = b; return true; } template <typename T> bool chmax(T &a, const T &b) { if (a >= b) return false; a = b; return true; } template <typename T> T max(vector<T> &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmax(ret, a[i]); return ret; } template <typename T> T min(vector<T> &a){ assert(!a.empty()); T ret = a[0]; for (int i=0; i<(int)a.size(); i++) chmin(ret, a[i]); return ret; } template <typename T> T sum(vector<T> &a){ T ret = 0; for (int i=0; i<(int)a.size(); i++) ret += a[i]; return ret; } int main(){ int x; int k; cin >> x >> k; assert(k<=10); mint gd=mint(x)/100; mint gf=mint(100-x)/100; mint ans = 0; rep(i,0,1<<2*k){ if(__builtin_popcount(i)!=k)continue; int t = 0; int g = 0; mint v = 1; bool mode = true; rep(j,0,2*k){ if (i>>j&1){ g++; v*=gd; }else{ g--; v*=gf; } if (g<0) mode=0; chmax(t, g); } if (mode){ ans += t*v; } } cout << ans.val() << '\n'; }