結果
問題 | No.2816 At Most Two Moves |
ユーザー |
|
提出日時 | 2024-07-19 22:43:33 |
言語 | C++23 (gcc 13.3.0 + boost 1.87.0) |
結果 |
AC
|
実行時間 | 5 ms / 2,000 ms |
コード長 | 914 bytes |
コンパイル時間 | 1,386 ms |
コンパイル使用メモリ | 90,816 KB |
実行使用メモリ | 5,376 KB |
最終ジャッジ日時 | 2024-07-19 22:43:38 |
合計ジャッジ時間 | 2,401 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 1 |
other | AC * 25 |
ソースコード
#include <iostream> #include <vector> #include <atcoder/modint> #ifdef LOCAL #include "cpp-dump/dump.hpp" #endif using namespace std; using ll = long long; using mint = atcoder::static_modint<998244353>; constexpr int iINF = 1'000'000'000; constexpr ll llINF = 1'000'000'000'000'000'000; int main () { int T; cin >> T; for (int i = 0; i < T; i++) { int N; cin >> N; if (N == 1) { cout << 1 << "\n"; continue; } if (N == 2) { cout << 3 << "\n"; continue; } mint E = 1; E /= 2; mint not_reach = 3; not_reach /= 4; not_reach = not_reach.pow(N - 2); E *= not_reach; // 余事象が到達可能数 E = 1 - E; mint pr = mint(2).pow(1LL * N * (N - 1) / 2); mint ans = (1 + (N - 1) * E) * pr; cout << ans.val() << "\n"; } }