結果

問題 No.1171 Runs in Subsequences
ユーザー yudedakoyudedako
提出日時 2020-08-28 16:09:39
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 432 ms / 2,000 ms
コード長 472 bytes
コンパイル時間 11,157 ms
コンパイル使用メモリ 427,488 KB
実行使用メモリ 54,384 KB
最終ジャッジ日時 2024-04-26 12:11:41
合計ジャッジ時間 19,875 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 311 ms
50,840 KB
testcase_01 AC 295 ms
50,976 KB
testcase_02 AC 290 ms
51,108 KB
testcase_03 AC 287 ms
50,940 KB
testcase_04 AC 284 ms
51,172 KB
testcase_05 AC 279 ms
51,028 KB
testcase_06 AC 287 ms
51,228 KB
testcase_07 AC 283 ms
51,204 KB
testcase_08 AC 291 ms
51,212 KB
testcase_09 AC 282 ms
50,900 KB
testcase_10 AC 293 ms
51,152 KB
testcase_11 AC 294 ms
50,824 KB
testcase_12 AC 287 ms
51,140 KB
testcase_13 AC 286 ms
51,036 KB
testcase_14 AC 280 ms
50,952 KB
testcase_15 AC 392 ms
54,068 KB
testcase_16 AC 432 ms
54,224 KB
testcase_17 AC 428 ms
54,316 KB
testcase_18 AC 397 ms
54,180 KB
testcase_19 AC 401 ms
54,384 KB
testcase_20 AC 396 ms
54,060 KB
testcase_21 AC 398 ms
54,160 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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)
}
0