結果

問題 No.164 ちっちゃくないよ!!
ユーザー バカらっくバカらっく
提出日時 2021-11-10 14:35:44
言語 Kotlin
(1.9.23)
結果
AC  
実行時間 359 ms / 2,000 ms
コード長 621 bytes
コンパイル時間 15,510 ms
コンパイル使用メモリ 453,032 KB
実行使用メモリ 59,480 KB
最終ジャッジ日時 2024-05-01 02:08:28
合計ジャッジ時間 16,269 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 270 ms
57,020 KB
testcase_01 AC 266 ms
56,996 KB
testcase_02 AC 293 ms
56,848 KB
testcase_03 AC 279 ms
56,912 KB
testcase_04 AC 267 ms
57,024 KB
testcase_05 AC 359 ms
59,480 KB
testcase_06 AC 356 ms
59,044 KB
testcase_07 AC 311 ms
57,264 KB
testcase_08 AC 314 ms
57,324 KB
testcase_09 AC 319 ms
57,464 KB
testcase_10 AC 270 ms
57,044 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.kt:2:10: warning: parameter 'args' is never used
fun main(args: Array<String>) {
         ^
Main.kt:10:16: warning: variable 'base' initializer is redundant
    var base = 10
               ^

ソースコード

diff #

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val ans = (1..n).map { convDec(readLine()!!) }.minOrNull()!!
    println(ans)
}

fun convDec(n:String):Long {
    val alpha = n.filter { it in 'A'..'Z' }
    var base = 10
    if(alpha.isEmpty()) {
        base = n.map { it.toString().toInt() }.maxOrNull()!! + 1
    } else {
        base = alpha.maxOrNull()!! - 'A' + 11
    }
    var mul = 1L
    var ans = 0L
    for(i in n.reversed()) {
        if(i in '0'..'9') {
            ans += (i-'0')*mul
        } else {
            ans += (i-'A'+10)*mul
        }
        mul*=base
    }
    return ans
}
0