結果
問題 |
No.1171 Runs in Subsequences
|
ユーザー |
|
提出日時 | 2020-08-28 16:09:39 |
言語 | Kotlin (2.1.0) |
結果 |
AC
|
実行時間 | 447 ms / 2,000 ms |
コード長 | 472 bytes |
コンパイル時間 | 15,879 ms |
コンパイル使用メモリ | 434,388 KB |
実行使用メモリ | 59,332 KB |
最終ジャッジ日時 | 2024-11-13 23:20:25 |
合計ジャッジ時間 | 20,441 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 18 |
ソースコード
fun main() { val mod = 1000000007L val str = readLine()!!.trim() val patternEndWith = LongArray(26){0L} var allPattern = 1L var allCount = 0L for (c in str) { val increasePattern = allPattern - patternEndWith[c - 'a'] + mod patternEndWith[c - 'a'] = (patternEndWith[c - 'a'] + allPattern) % mod allPattern = (allPattern shl 1) % mod allCount = ((allCount shl 1) + increasePattern) % mod } println(allCount) }