結果

問題 No.170 スワップ文字列(Easy)
ユーザー rutilicusrutilicus
提出日時 2020-09-08 21:18:37
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 279 ms / 5,000 ms
コード長 464 bytes
コンパイル時間 19,360 ms
コンパイル使用メモリ 418,288 KB
実行使用メモリ 53,052 KB
最終ジャッジ日時 2023-08-20 07:39:23
合計ジャッジ時間 23,439 ms
ジャッジサーバーID
(参考情報)
judge13 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 270 ms
52,804 KB
testcase_01 AC 268 ms
52,816 KB
testcase_02 AC 270 ms
52,624 KB
testcase_03 AC 274 ms
53,052 KB
testcase_04 AC 275 ms
52,720 KB
testcase_05 AC 273 ms
52,920 KB
testcase_06 AC 276 ms
52,820 KB
testcase_07 AC 273 ms
52,768 KB
testcase_08 AC 271 ms
52,816 KB
testcase_09 AC 275 ms
52,800 KB
testcase_10 AC 279 ms
52,676 KB
testcase_11 AC 279 ms
52,824 KB
testcase_12 AC 272 ms
52,688 KB
testcase_13 AC 275 ms
52,796 KB
testcase_14 AC 273 ms
52,816 KB
testcase_15 AC 276 ms
52,756 KB
testcase_16 AC 275 ms
52,812 KB
testcase_17 AC 270 ms
52,796 KB
testcase_18 AC 274 ms
52,756 KB
testcase_19 AC 275 ms
52,936 KB
testcase_20 AC 274 ms
52,876 KB
testcase_21 AC 274 ms
52,756 KB
testcase_22 AC 278 ms
52,760 KB
testcase_23 AC 273 ms
52,732 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:18:11: warning: variable 'c' is never used
    for ((c, ccnt) in cnt) {
          ^
Main.kt:24:13: warning: 'appendln(Int): kotlin.text.StringBuilder /* = java.lang.StringBuilder */' is deprecated. Use appendLine instead. Note that the new method always appends the line feed character '\n' regardless of the system line separator.
    builder.appendln(ans - 1)
            ^

ソースコード

diff #

fun main() {
    val builder = StringBuilder()

    val cnt = mutableMapOf<Char, Int>()

    val s = readInputLine()

    s.forEach {
        cnt[it] = (cnt[it] ?: 0) + 1
    }

    var ans = 1

    for (i in 1..s.length) {
        ans *= i
    }

    for ((c, ccnt) in cnt) {
        for (i in 1..ccnt) {
            ans /= i
        }
    }

    builder.appendln(ans - 1)

    print(builder.toString())
}

fun readInputLine(): String {
    return readLine()!!
}
0