結果
| 問題 |
No.3146 RE: Parentheses Counting
|
| コンテスト | |
| ユーザー |
👑 potato167
|
| 提出日時 | 2025-05-16 21:54:21 |
| 言語 | C++17 (gcc 13.3.0 + boost 1.87.0) |
| 結果 |
WA
|
| 実行時間 | - |
| コード長 | 911 bytes |
| コンパイル時間 | 1,795 ms |
| コンパイル使用メモリ | 198,612 KB |
| 実行使用メモリ | 11,192 KB |
| 最終ジャッジ日時 | 2025-05-16 21:54:34 |
| 合計ジャッジ時間 | 11,057 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 1 |
| other | WA * 43 |
ソースコード
#include <bits/stdc++.h>
using namespace std;
#define all(p) p.begin(), p.end()
#define rep(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#include<atcoder/modint>
using mint = atcoder::modint998244353;
//https://yukicoder.me/submissions/1047130
int main(){
int T;
cin >> T;
const int L = 1'000'010;
vector<mint> fact(L, 1), fact_inv(L, 1);
rep(i, 1, L) fact[i] = fact[i - 1] * i;
fact_inv.back() = fact.back().inv();
for (int i = L - 1; i > 0; i--) fact_inv[i - 1] = fact_inv[i] * i;
auto f = [&](int a, int b) -> mint {
return fact[a] * fact_inv[a - b] * fact_inv[b];
};
while (T--){
int N;
cin >> N;
if (N & 1){
cout << "0\n";
}
else{
int n = N / 2;
n--;
cout << (((mint)(2)).pow(2 * n + 1) - f(2 * n + 3, n + 1) + f(2 * n + 1, n)).val() << "\n";
}
}
}
potato167