結果

問題 No.164 ちっちゃくないよ!!
ユーザー yuki2006yuki2006
提出日時 2015-03-12 20:15:45
言語 Go
(1.22.1)
結果
AC  
実行時間 2 ms / 2,000 ms
コード長 1,503 bytes
コンパイル時間 11,852 ms
コンパイル使用メモリ 220,620 KB
実行使用メモリ 5,376 KB
最終ジャッジ日時 2024-04-22 15:39:25
合計ジャッジ時間 12,870 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

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

ソースコード

diff #

package main

import (
	"bufio"
	"os"
	"strconv"
	"fmt"
)

var _s = bufio.NewScanner(os.Stdin)

func next() string {
	_s.Scan()
	return _s.Text()
}
func nextLine() string {
	_s.Scan()
	return _s.Text()
}

func nextInt() int {
	i, e := strconv.Atoi(next())
	if e != nil {
		panic(e)
	}
	return i
}
func nextLong() int64 {
	i, e := strconv.ParseInt(next(), 10, 64)
	if e != nil {
		panic(e)
	}
	return i
}

//aのb乗をします
func pow(a int, b int) int {
	total := 1
	tmp := a
	for b > 0 {
		if b%2 == 1 {
			total*=tmp
		}
		b/=2
		tmp*=tmp
	}
	return total
}

/**
 与えられた文字を32進数とみなして値を返します。
 */
func getNumber(c uint8) int {
	if '0' <= c && c <= '9' {
		return int(c - '0')
	}else if 'A' <= c && c <= 'Z' {
		return int(c - 'A') + 10
	}else if 'a' <= c && c <= 'z' {
		return int(c - 'a') + 10
	}
	panic("")
}
func getNumberBase(s string, base int) (int) {
	k := 1
	total := 0
	for i := len(s) - 1; i >= 0; i-- {
		number := getNumber(s[i])
		if number >= base {
			return -1
		}
		total+=number*k
		k*=base
	}
	return total
}

func getMinNumberBase(s string) int {
	mn := getNumberBase("ZZZZZZZZZZZZ", 36)
	for i := 2; i <= 36; i++ {
		v := getNumberBase(s, i)
		if v == -1 {
			continue
		}
		if mn > v {
			mn = v
		}
	}

	return mn
}

func main() {

	N,_ := strconv.Atoi(nextLine())
	s := nextLine()

	mn := getMinNumberBase(s)

	for i := 1; i < N; i++ {
		s := nextLine()
		v := getMinNumberBase(s)
		if mn > v {
			mn = v
		}
	}
	fmt.Println(mn)


}
0