結果
問題 | No.915 Plus Or Multiple Operation |
ユーザー | rutilicus |
提出日時 | 2020-11-01 11:50:49 |
言語 | Kotlin (1.9.23) |
結果 |
AC
|
実行時間 | 334 ms / 2,000 ms |
コード長 | 894 bytes |
コンパイル時間 | 14,713 ms |
コンパイル使用メモリ | 440,576 KB |
実行使用メモリ | 52,080 KB |
最終ジャッジ日時 | 2024-04-24 19:02:04 |
合計ジャッジ時間 | 18,047 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 334 ms
52,016 KB |
testcase_01 | AC | 320 ms
51,972 KB |
testcase_02 | AC | 328 ms
52,080 KB |
testcase_03 | AC | 328 ms
51,812 KB |
testcase_04 | AC | 330 ms
51,756 KB |
testcase_05 | AC | 325 ms
51,960 KB |
testcase_06 | AC | 325 ms
51,776 KB |
testcase_07 | AC | 318 ms
51,740 KB |
testcase_08 | AC | 319 ms
51,984 KB |
testcase_09 | AC | 320 ms
51,728 KB |
testcase_10 | AC | 321 ms
51,792 KB |
testcase_11 | AC | 326 ms
51,864 KB |
testcase_12 | AC | 323 ms
52,076 KB |
コンパイルメッセージ
Main.kt:12:21: 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(-1) ^ Main.kt:27:21: warning: 'appendln(Long): 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(ansCandidates.min()!! * b) ^ Main.kt:27:49: warning: unnecessary non-null assertion (!!) on a non-null receiver of type Long builder.appendln(ansCandidates.min()!! * b) ^
ソースコード
fun main() { val builder = StringBuilder() val q = readInputLine().toInt() // 有志解説を読んでもよくわからない…… repeat(q) { val (a, b, c) = readInputLine().split(" ").map { it.toLong() } if (c == 1L) { builder.appendln(-1) } else { var tmp = a var cnt = 0L val ansCandidates = mutableSetOf<Long>() while (tmp != 0L) { if (tmp % c == 0L) { tmp /= c } else { ansCandidates.add(cnt + (tmp + c - 2L) / (c - 1L)) tmp = tmp / c * c } cnt++ } ansCandidates.add(cnt) builder.appendln(ansCandidates.min()!! * b) } } print(builder.toString()) } fun readInputLine(): String { return readLine()!! }