結果
問題 | No.1740 Alone 'a' |
ユーザー |
![]() |
提出日時 | 2021-11-12 22:41:08 |
言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
結果 |
AC
|
実行時間 | 302 ms / 2,000 ms |
コード長 | 639 bytes |
コンパイル時間 | 287 ms |
コンパイル使用メモリ | 12,544 KB |
実行使用メモリ | 11,136 KB |
最終ジャッジ日時 | 2024-11-25 20:19:25 |
合計ジャッジ時間 | 6,808 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 38 |
ソースコード
import sysinput = sys.stdin.readlineN=int(input())S=input().strip()mod=998244353DP0=1 # 一致、a含まずDP1=0 # 一致、a含むDP2=0 # 一致せず、a含まずDP3=0 # 一致せず、a含むfor s in S:NDP0=0NDP1=0NDP2=0NDP3=0if s=="a":NDP0=0NDP1+=DP0NDP2+=DP2*25NDP3+=DP2+DP3*25else:x=ord(s)NDP0+=DP0NDP1+=DP1NDP2+=DP0*(x-98)+DP2*25NDP3+=DP0+DP1*(x-98)+DP2+DP3*25DP0=NDP0%modDP1=NDP1%modDP2=NDP2%modDP3=NDP3%mod#print(DP0,DP1,DP2,DP3)print((DP3)%mod)