結果

問題 No.2816 At Most Two Moves
ユーザー hitonanode
提出日時 2024-07-19 22:44:44
言語 C++23
(gcc 13.3.0 + boost 1.87.0)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 535 bytes
コンパイル時間 687 ms
コンパイル使用メモリ 82,816 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-07-19 22:44:48
合計ジャッジ時間 1,517 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 1
other AC * 25
権限があれば一括ダウンロードができます

ソースコード

diff #

#include <iostream>
#include <atcoder/modint>
using namespace std;

using mint = atcoder::modint998244353;

mint solve(int N) {
    if (N == 1) return 1;
    const auto E = (long long)(N) * (N - 1) / 2;

    mint e = 1 + mint(N - 1) / 2;

    e += mint(N - 1) * mint(2).inv() * (mint(1) - (mint(3) / 4).pow(N - 2));

    return e * mint(2).pow(E);
}

int main() {
    cin.tie(nullptr)->sync_with_stdio(false);

    int T;
    cin >> T;
    while (T--) {
        int N;
        cin >> N;
        cout << solve(N).val() << '\n';
    }
}
0