結果
問題 | No.915 Plus Or Multiple Operation |
ユーザー |
![]() |
提出日時 | 2020-11-01 11:50:11 |
言語 | Kotlin (2.1.0) |
結果 |
AC
|
実行時間 | 335 ms / 2,000 ms |
コード長 | 900 bytes |
コンパイル時間 | 13,579 ms |
コンパイル使用メモリ | 438,548 KB |
実行使用メモリ | 56,988 KB |
最終ジャッジ日時 | 2024-11-07 03:51:33 |
合計ジャッジ時間 | 18,762 ms |
ジャッジサーバーID (参考情報) |
judge3 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 3 |
other | AC * 10 |
コンパイルメッセージ
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.minOrNull()!! * 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.minOrNull()!! * b) } } print(builder.toString()) } fun readInputLine(): String { return readLine()!! }