結果

問題 No.1755 Almost Palindrome
ユーザー 👑 rin204rin204
提出日時 2022-09-10 17:08:11
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 385 ms / 2,000 ms
コード長 395 bytes
コンパイル時間 607 ms
コンパイル使用メモリ 86,732 KB
実行使用メモリ 77,472 KB
最終ジャッジ日時 2023-08-17 21:21:34
合計ジャッジ時間 1,643 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,060 KB
testcase_01 AC 74 ms
71,124 KB
testcase_02 AC 385 ms
77,472 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
        mi = pow(26, n // 2, MOD) - 26
        ans -= mi
        return ans % MOD




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