結果
| 問題 | 
                            No.915 Plus Or Multiple Operation
                             | 
                    
| コンテスト | |
| ユーザー | 
                             rutilicus
                         | 
                    
| 提出日時 | 2020-11-01 11:50:49 | 
| 言語 | Kotlin  (2.1.0)  | 
                    
| 結果 | 
                             
                                AC
                                 
                             
                            
                         | 
                    
| 実行時間 | 333 ms / 2,000 ms | 
| コード長 | 894 bytes | 
| コンパイル時間 | 12,260 ms | 
| コンパイル使用メモリ | 436,668 KB | 
| 実行使用メモリ | 57,156 KB | 
| 最終ジャッジ日時 | 2024-11-07 03:52:15 | 
| 合計ジャッジ時間 | 17,718 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge2 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| 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.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()!!
}
            
            
            
        
            
rutilicus