結果

問題 No.1755 Almost Palindrome
ユーザー rin204rin204
提出日時 2022-09-10 17:05:37
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 332 ms / 2,000 ms
コード長 432 bytes
コンパイル時間 497 ms
コンパイル使用メモリ 82,048 KB
実行使用メモリ 76,288 KB
最終ジャッジ日時 2024-05-05 04:11:05
合計ジャッジ時間 1,213 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 36 ms
51,968 KB
testcase_01 AC 40 ms
51,712 KB
testcase_02 AC 332 ms
76,288 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353

def solve(n):
    if n & 1:
        x = pow(26, n // 2, MOD)
        x *= 25 * (n - 1)
        return x % MOD
    else:
        x = pow(26, n // 2 - 1, MOD)
        ans = x * 26 * 25 % MOD
        ans += x * 26 * 25 * (n - 2) % MOD
        if n >= 4:
            mi = 676 * pow(26, n // 2 - 2, MOD) - 26
            ans -= mi
        return ans % MOD




for _ in range(int(input())):
    print(solve(int(input())))
0