結果

問題 No.164 ちっちゃくないよ!!
コンテスト
ユーザー Pump0129
提出日時 2018-04-05 03:50:15
言語 Kotlin
(2.4.10 + ACL)
コンパイル:
kotlinc -cp /opt/aclib/ac_library.jar _filename_ -include-runtime -d main.jar
実行:
java -cp main.jar:/opt/aclib/ac_library.jar _class_
結果
WA  
実行時間 -
コード長 1,068 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 8,429 ms
コンパイル使用メモリ 514,384 KB
実行使用メモリ 50,940 KB
最終ジャッジ日時 2026-09-27 02:08:27
合計ジャッジ時間 11,529 ms
ジャッジサーバーID
(参考情報)
judge4_0 / judge1_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 10 WA * 1
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

package net.ipipip0129.kotlin.yukicoder

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): Long {
    var output = 0L
    num.reversed().forEachIndexed { index, c -> output += (decimal).toDouble().pow(index).toLong() * charToDecimalInt(c) }
    return output
}
0