結果

問題 No.164 ちっちゃくないよ!!
ユーザー Pump0129Pump0129
提出日時 2018-04-05 04:03:32
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 416 ms / 2,000 ms
コード長 973 bytes
コンパイル時間 14,543 ms
コンパイル使用メモリ 427,848 KB
実行使用メモリ 56,888 KB
最終ジャッジ日時 2023-08-12 23:03:07
合計ジャッジ時間 17,676 ms
ジャッジサーバーID
(参考情報)
judge9 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 300 ms
52,980 KB
testcase_01 AC 307 ms
53,008 KB
testcase_02 AC 308 ms
53,104 KB
testcase_03 AC 292 ms
52,944 KB
testcase_04 AC 298 ms
53,528 KB
testcase_05 AC 406 ms
56,604 KB
testcase_06 AC 416 ms
56,472 KB
testcase_07 AC 381 ms
56,424 KB
testcase_08 AC 412 ms
56,636 KB
testcase_09 AC 398 ms
56,888 KB
testcase_10 AC 309 ms
53,472 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:8:10: warning: parameter 'args' is never used
fun main(args: Array<String>) {
         ^
Main.kt:14:61: warning: unnecessary non-null assertion (!!) on a non-null receiver of type Char
    val decimalArray = lines.map { charToDecimalInt(it.max()!!) + 1 }.requireNoNulls()
                                                            ^
Main.kt:22:14: warning: 'toInt(): Int' is deprecated. Conversion of Char to Number is deprecated. Use Char.code property instead.
        char.toInt() - CHAR_TO_INT
             ^

ソースコード

diff #

package net.ipipip0129.kotlin.yukicoder

import java.math.BigInteger
import kotlin.math.pow

const val CHAR_TO_INT = 55

fun main(args: Array<String>) {
    val count = readLine()!!.toInt()

    // 値読み込み 先頭の0を除去
    val lines = (0 until count).map { readLine()!!.replace("^0*".toRegex(), "") }.requireNoNulls()
    // 各値の進数を格納
    val decimalArray = lines.map { charToDecimalInt(it.max()!!) + 1 }.requireNoNulls()
    // すべてを10進数に変換し最小値を出力
    println(lines.mapIndexed( {index, s ->  convertDecimal(s, decimalArray[index]) }).min())
}

// 文字をN進数へ変換
fun charToDecimalInt(char: Char): Int {
    return if (!char.toString().contains(Regex("""\d"""))) {
        char.toInt() - CHAR_TO_INT
    } else {
        char.toString().toInt()
    }
}

// 10進数へ変換
fun convertDecimal(num: String, decimal: Int): BigInteger {
    return BigInteger(num, decimal)
}
0