結果
| 問題 |
No.170 スワップ文字列(Easy)
|
| コンテスト | |
| ユーザー |
rutilicus
|
| 提出日時 | 2020-09-08 21:18:37 |
| 言語 | Kotlin (2.1.0) |
| 結果 |
AC
|
| 実行時間 | 279 ms / 5,000 ms |
| コード長 | 464 bytes |
| コンパイル時間 | 13,869 ms |
| コンパイル使用メモリ | 440,120 KB |
| 実行使用メモリ | 52,680 KB |
| 最終ジャッジ日時 | 2024-11-30 08:31:09 |
| 合計ジャッジ時間 | 20,547 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 3 |
| other | AC * 21 |
コンパイルメッセージ
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)
^
ソースコード
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()!!
}
rutilicus