結果

問題 No.164 ちっちゃくないよ!!
ユーザー tsuchinagatsuchinaga
提出日時 2019-03-22 08:55:55
言語 Go
(1.21.3)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 717 bytes
コンパイル時間 13,842 ms
コンパイル使用メモリ 209,808 KB
実行使用メモリ 4,348 KB
最終ジャッジ日時 2023-10-19 05:57:37
合計ジャッジ時間 14,432 ms
ジャッジサーバーID
(参考情報)
judge11 / judge12
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 1 ms
4,348 KB
testcase_01 AC 1 ms
4,348 KB
testcase_02 AC 2 ms
4,348 KB
testcase_03 AC 1 ms
4,348 KB
testcase_04 AC 1 ms
4,348 KB
testcase_05 AC 1 ms
4,348 KB
testcase_06 AC 2 ms
4,348 KB
testcase_07 AC 1 ms
4,348 KB
testcase_08 AC 1 ms
4,348 KB
testcase_09 AC 1 ms
4,348 KB
testcase_10 AC 1 ms
4,348 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
)

func main() {
	var n int
	_, _ = fmt.Scan(&n)

	sc := bufio.NewScanner(os.Stdin)
	min := math.MaxInt64
	for i := 0; i < n; i++ {
		sc.Scan()
		s := sc.Text()

		max := 0
		for _, r := range []rune(s) {
			a := int(r)
			if '0' <= a && a <= '9' {
				a = a - '0'
			} else {
				a = a - 'A' + 10
			}
			if max < a {
				max = a
			}
		}

		num := toDecimal164(s, max+1)
		if min > num {
			min = num
		}
	}
	fmt.Println(min)
}

func toDecimal164(s string, i int) int {
	n := 0
	for _, r := range []rune(s) {
		a := int(r)
		if '0' <= a && a <= '9' {
			a = a - '0'
		} else {
			a = a - 'A' + 10
		}
		// fmt.Println(string(r), a)

		n = n*i + a
	}
	return n
}
0