結果

問題 No.1755 Almost Palindrome
ユーザー 👑 rin204rin204
提出日時 2022-09-10 17:07:44
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 869 ms / 2,000 ms
コード長 405 bytes
コンパイル時間 315 ms
コンパイル使用メモリ 10,592 KB
実行使用メモリ 7,848 KB
最終ジャッジ日時 2023-08-17 21:21:19
合計ジャッジ時間 1,705 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,748 KB
testcase_01 AC 16 ms
7,848 KB
testcase_02 AC 869 ms
7,828 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 = 676 * pow(26, n // 2 - 2, MOD) - 26
        ans -= mi
        return ans % MOD




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