結果
| 問題 | No.915 Plus Or Multiple Operation |
| コンテスト | |
| ユーザー |
rutilicus
|
| 提出日時 | 2020-11-01 11:50:49 |
| 言語 | Kotlin (2.3.0) |
| 結果 |
CE
(最新)
AC
(最初)
|
| 実行時間 | - |
| コード長 | 894 bytes |
| 記録 | |
| コンパイル時間 | 8,576 ms |
| コンパイル使用メモリ | 418,264 KB |
| 最終ジャッジ日時 | 2025-12-13 22:26:33 |
| 合計ジャッジ時間 | 9,199 ms |
|
ジャッジサーバーID (参考情報) |
judge4 / judge5 |
(要ログイン)
コンパイルエラー時のメッセージ・ソースコードは、提出者また管理者しか表示できないようにしております。(リジャッジ後のコンパイルエラーは公開されます)
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
ただし、clay言語の場合は開発者のデバッグのため、公開されます。
コンパイルメッセージ
Main.kt:12:21: error: 'fun StringBuilder.appendln(value: Int): 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: error: 'fun StringBuilder.appendln(value: Long): 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)
^^^^^^^^
ソースコード
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()!!
}
rutilicus