package Yukicoder /** * Created by hichikawa on 2015/11/12. */ fun main(args: Array) { fun readLineLongArray(): List { val str = readLine() as String val arrStr = str.split(" ") val ret = arrStr.map { it.toLong() } return ret } fun readLineLong(): Long { val str = readLine() as String return str.toLong() } fun readLineInt(): Int { val str = readLine() as String return str.toInt() } fun readLineIntArray() : List { val str = readLine() as String val arrStr = str.split(" ") val ret = arrStr.map { it.toInt() } return ret } fun readLineDoubleArray(): List { val str = readLine() as String val arrStr = str.split(" ") val ret = arrStr.map { it.toDouble() } return ret } fun readLineDouble() : Double { val str = readLine() as String return str.toDouble() } fun calcNsinsu(str : String) : Int { val strList = "ZYXWVUTSRQPONMLKJIHGFEDCBA9876543210" for ((i, ch) in strList.withIndex()) { if (str.indexOf(ch) != -1) { return (36-i) } } return -1 } fun calcNum (str: String , shinsu : Int) : Long { val strList = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ" var ret : Long = 0 for (ch in str) { ret *= shinsu ret += strList.indexOf(ch) } return ret } val num = readLineInt() var minValue = Long.MAX_VALUE for (i in 1..num) { val tmpS = readLine() as String val tmp = calcNum(tmpS, calcNsinsu(tmpS)) if (minValue > tmp) { minValue = tmp } } println(minValue) }