結果

問題 No.1740 Alone 'a'
ユーザー lloyz
提出日時 2021-11-13 11:19:27
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 611 bytes
コンパイル時間 221 ms
コンパイル使用メモリ 81,920 KB
実行使用メモリ 69,632 KB
最終ジャッジ日時 2024-11-27 04:11:03
合計ジャッジ時間 3,376 ms
ジャッジサーバーID
(参考情報)
judge1 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other AC * 5 WA * 33
権限があれば一括ダウンロードができます

ソースコード

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
else:
    ans += ord(S[-1]) - ord('b')
    ans %= mod
print(ans)

0