結果

問題 No.1740 Alone 'a'
ユーザー lloyzlloyz
提出日時 2021-11-13 11:21:05
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 639 bytes
コンパイル時間 142 ms
コンパイル使用メモリ 82,432 KB
実行使用メモリ 69,888 KB
最終ジャッジ日時 2024-05-05 08:53:52
合計ジャッジ時間 3,207 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 40 ms
52,224 KB
testcase_01 AC 36 ms
52,096 KB
testcase_02 AC 35 ms
51,712 KB
testcase_03 AC 193 ms
69,760 KB
testcase_04 AC 207 ms
69,888 KB
testcase_05 WA -
testcase_06 WA -
testcase_07 WA -
testcase_08 AC 36 ms
51,968 KB
testcase_09 AC 37 ms
51,840 KB
testcase_10 AC 39 ms
51,840 KB
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 WA -
testcase_18 WA -
testcase_19 WA -
testcase_20 WA -
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 44 ms
56,960 KB
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 41 ms
59,648 KB
testcase_32 WA -
testcase_33 WA -
testcase_34 WA -
testcase_35 WA -
testcase_36 WA -
testcase_37 WA -
testcase_38 WA -
testcase_39 WA -
testcase_40 WA -
権限があれば一括ダウンロードができます

ソースコード

diff #

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

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

0