結果

問題 No.1740 Alone 'a'
ユーザー H3PO4H3PO4
提出日時 2021-11-12 22:13:30
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 90 ms / 2,000 ms
コード長 569 bytes
コンパイル時間 581 ms
コンパイル使用メモリ 87,168 KB
実行使用メモリ 78,796 KB
最終ジャッジ日時 2023-08-17 01:54:51
合計ジャッジ時間 5,412 ms
ジャッジサーバーID
(参考情報)
judge15 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,132 KB
testcase_01 AC 71 ms
71,440 KB
testcase_02 AC 73 ms
71,124 KB
testcase_03 AC 90 ms
78,796 KB
testcase_04 AC 88 ms
78,688 KB
testcase_05 AC 74 ms
75,924 KB
testcase_06 AC 77 ms
76,028 KB
testcase_07 AC 73 ms
71,676 KB
testcase_08 AC 71 ms
71,308 KB
testcase_09 AC 72 ms
71,524 KB
testcase_10 AC 70 ms
71,592 KB
testcase_11 AC 73 ms
76,284 KB
testcase_12 AC 76 ms
77,476 KB
testcase_13 AC 77 ms
77,252 KB
testcase_14 AC 80 ms
77,608 KB
testcase_15 AC 77 ms
75,984 KB
testcase_16 AC 79 ms
77,220 KB
testcase_17 AC 76 ms
76,096 KB
testcase_18 AC 79 ms
76,084 KB
testcase_19 AC 78 ms
77,352 KB
testcase_20 AC 77 ms
76,580 KB
testcase_21 AC 80 ms
76,788 KB
testcase_22 AC 78 ms
77,264 KB
testcase_23 AC 77 ms
77,344 KB
testcase_24 AC 77 ms
76,448 KB
testcase_25 AC 76 ms
76,580 KB
testcase_26 AC 77 ms
76,788 KB
testcase_27 AC 78 ms
76,856 KB
testcase_28 AC 79 ms
76,696 KB
testcase_29 AC 78 ms
77,804 KB
testcase_30 AC 77 ms
76,780 KB
testcase_31 AC 76 ms
77,392 KB
testcase_32 AC 78 ms
76,596 KB
testcase_33 AC 79 ms
77,176 KB
testcase_34 AC 75 ms
76,368 KB
testcase_35 AC 78 ms
76,784 KB
testcase_36 AC 77 ms
76,596 KB
testcase_37 AC 76 ms
76,112 KB
testcase_38 AC 77 ms
76,312 KB
testcase_39 AC 76 ms
75,780 KB
testcase_40 AC 76 ms
76,252 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

en2asc = lambda s: ord(s) - 97

N = int(input())
S = input()
MOD = 998244353

p25 = [1] * N
for i in range(1, N):
    p25[i] = p25[i - 1] * 25 % MOD

ct_a = 0
ans = 0
for i, s in enumerate(S):
    a = en2asc(s)
    if a:
        # s != "a"
        if ct_a == 0:
            if i != N - 1:
                ans += (a - 1) * (N - i - 1) * p25[N - i - 2]
            ans += p25[N - i - 1]
        elif ct_a == 1:
            ans += (a - 1) * p25[N - i - 1]
        ans %= MOD
    else:
        # s == "a"
        ct_a += 1
        if ct_a > 1:
            break
print(ans)
0