結果
| 問題 | No.2816 At Most Two Moves |
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2024-07-19 22:43:33 |
| 言語 | C++23 (gcc 15.2.0 + boost 1.89.0) |
| 結果 |
AC
|
| 実行時間 | 4 ms / 2,000 ms |
| コード長 | 914 bytes |
| 記録 | |
| コンパイル時間 | 1,166 ms |
| コンパイル使用メモリ | 165,276 KB |
| 実行使用メモリ | 173,244 KB |
| 最終ジャッジ日時 | 2026-04-02 18:44:51 |
| 合計ジャッジ時間 | 6,280 ms |
|
ジャッジサーバーID (参考情報) |
judge2_0 / judge4_1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| 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";
}
}