結果
| 問題 |
No.164 ちっちゃくないよ!!
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2015-03-12 20:15:45 |
| 言語 | Go (1.23.4) |
| 結果 |
AC
|
| 実行時間 | 2 ms / 2,000 ms |
| コード長 | 1,503 bytes |
| コンパイル時間 | 13,300 ms |
| コンパイル使用メモリ | 236,844 KB |
| 実行使用メモリ | 6,824 KB |
| 最終ジャッジ日時 | 2024-10-14 14:45:25 |
| 合計ジャッジ時間 | 13,347 ms |
|
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 11 |
ソースコード
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)
}