結果

問題 No.1740 Alone 'a'
ユーザー lloyzlloyz
提出日時 2021-11-13 19:51:23
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 254 ms / 2,000 ms
コード長 535 bytes
コンパイル時間 402 ms
コンパイル使用メモリ 87,288 KB
実行使用メモリ 79,924 KB
最終ジャッジ日時 2023-08-18 14:28:26
合計ジャッジ時間 6,097 ms
ジャッジサーバーID
(参考情報)
judge14 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,660 KB
testcase_01 AC 79 ms
71,488 KB
testcase_02 AC 74 ms
71,332 KB
testcase_03 AC 254 ms
79,924 KB
testcase_04 AC 251 ms
79,916 KB
testcase_05 AC 77 ms
71,464 KB
testcase_06 AC 75 ms
71,580 KB
testcase_07 AC 75 ms
71,328 KB
testcase_08 AC 76 ms
71,364 KB
testcase_09 AC 75 ms
71,340 KB
testcase_10 AC 75 ms
71,580 KB
testcase_11 AC 77 ms
72,048 KB
testcase_12 AC 80 ms
74,272 KB
testcase_13 AC 81 ms
74,148 KB
testcase_14 AC 80 ms
74,744 KB
testcase_15 AC 74 ms
71,204 KB
testcase_16 AC 81 ms
73,888 KB
testcase_17 AC 76 ms
71,404 KB
testcase_18 AC 77 ms
71,744 KB
testcase_19 AC 80 ms
74,192 KB
testcase_20 AC 77 ms
72,776 KB
testcase_21 AC 76 ms
73,152 KB
testcase_22 AC 78 ms
73,568 KB
testcase_23 AC 81 ms
73,776 KB
testcase_24 AC 77 ms
72,988 KB
testcase_25 AC 77 ms
72,816 KB
testcase_26 AC 77 ms
73,244 KB
testcase_27 AC 78 ms
73,380 KB
testcase_28 AC 79 ms
72,920 KB
testcase_29 AC 79 ms
74,748 KB
testcase_30 AC 79 ms
73,252 KB
testcase_31 AC 81 ms
74,092 KB
testcase_32 AC 78 ms
72,948 KB
testcase_33 AC 79 ms
73,800 KB
testcase_34 AC 76 ms
72,100 KB
testcase_35 AC 77 ms
73,088 KB
testcase_36 AC 80 ms
72,928 KB
testcase_37 AC 76 ms
71,976 KB
testcase_38 AC 77 ms
72,644 KB
testcase_39 AC 77 ms
71,356 KB
testcase_40 AC 77 ms
72,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
S = list(input())
mod = 998244353

ans = 0
a_cnt = 0
for i in range(n):
    if S[i] != 'a':
        if a_cnt == 0:
            ans += pow(25, n - i - 1, mod)
            ans %= mod
            if i < n - 1:
                ans += (ord(S[i]) - ord('b')) * (n - i - 1) * pow(25, n - i - 2, mod)
                ans %= mod
        elif a_cnt == 1:
            ans += (ord(S[i]) - ord('b')) * pow(25, n - i - 1, mod)
            ans %= mod
    else:
        a_cnt += 1
        if a_cnt == 2:
            break
print(ans)

0