結果

問題 No.1740 Alone 'a'
ユーザー horitaka1999horitaka1999
提出日時 2021-11-12 22:50:52
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 258 ms / 2,000 ms
コード長 624 bytes
コンパイル時間 278 ms
コンパイル使用メモリ 87,196 KB
実行使用メモリ 79,968 KB
最終ジャッジ日時 2023-08-17 03:12:22
合計ジャッジ時間 5,650 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 71 ms
71,412 KB
testcase_01 AC 74 ms
71,472 KB
testcase_02 AC 73 ms
71,280 KB
testcase_03 AC 258 ms
79,968 KB
testcase_04 AC 253 ms
79,820 KB
testcase_05 AC 73 ms
75,836 KB
testcase_06 AC 74 ms
76,084 KB
testcase_07 AC 71 ms
71,304 KB
testcase_08 AC 70 ms
71,404 KB
testcase_09 AC 68 ms
71,400 KB
testcase_10 AC 68 ms
71,276 KB
testcase_11 AC 75 ms
76,672 KB
testcase_12 AC 83 ms
78,808 KB
testcase_13 AC 81 ms
78,828 KB
testcase_14 AC 83 ms
79,292 KB
testcase_15 AC 69 ms
75,980 KB
testcase_16 AC 81 ms
78,488 KB
testcase_17 AC 72 ms
76,044 KB
testcase_18 AC 74 ms
76,428 KB
testcase_19 AC 82 ms
78,744 KB
testcase_20 AC 78 ms
77,476 KB
testcase_21 AC 80 ms
77,708 KB
testcase_22 AC 83 ms
78,252 KB
testcase_23 AC 83 ms
78,384 KB
testcase_24 AC 80 ms
77,352 KB
testcase_25 AC 78 ms
77,368 KB
testcase_26 AC 81 ms
77,852 KB
testcase_27 AC 79 ms
77,940 KB
testcase_28 AC 81 ms
77,268 KB
testcase_29 AC 86 ms
79,168 KB
testcase_30 AC 83 ms
77,688 KB
testcase_31 AC 84 ms
78,428 KB
testcase_32 AC 79 ms
77,512 KB
testcase_33 AC 82 ms
78,492 KB
testcase_34 AC 75 ms
76,340 KB
testcase_35 AC 80 ms
77,472 KB
testcase_36 AC 79 ms
77,112 KB
testcase_37 AC 74 ms
76,432 KB
testcase_38 AC 78 ms
77,044 KB
testcase_39 AC 76 ms
76,048 KB
testcase_40 AC 75 ms
76,596 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = int(input())
S = list(input())
store = set()
ans = 0
cnt = 0
mod = 998244353
def change(s):
    return ord(s) - ord('a') + 1
for i in  range(N):
    store.add(S[i])
    if S[i] == 'a':
        cnt += 1
    if cnt >= 2:
        continue
    if 'a' in store:
        tmp = (change(S[i]) -2) * pow(25,N-1-i,mod)
        if tmp > 0:
            ans += tmp
            ans %= mod
    else:
        if N -1 - i > 0:
            tmp = (change(S[i]) -2) * pow(25,N-1-i-1,mod) * (N-1-i)
            if tmp > 0:
                ans += tmp
                ans %= mod
        ans += pow(25,N-1-i,mod)
        ans %= mod
print(ans)

0