結果
| 問題 |
No.1740 Alone 'a'
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2021-11-12 22:50:52 |
| 言語 | PyPy3 (7.3.15) |
| 結果 |
AC
|
| 実行時間 | 216 ms / 2,000 ms |
| コード長 | 624 bytes |
| コンパイル時間 | 240 ms |
| コンパイル使用メモリ | 81,920 KB |
| 実行使用メモリ | 70,528 KB |
| 最終ジャッジ日時 | 2024-11-25 20:41:35 |
| 合計ジャッジ時間 | 3,747 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 38 |
ソースコード
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)