package main
import (
"bufio"
"os"
)
func getValue(r rune) uint64 {
switch r {
case '0':
return 0
case '1':
return 1
case '2':
return 2
case '3':
return 3
case '4':
return 4
case '5':
return 5
case '6':
return 6
case '7':
return 7
case '8':
return 8
case '9':
return 9
case 'a':
return 10
case 'A':
return 10
case 'b':
return 11
case 'B':
return 11
case 'c':
return 12
case 'C':
return 12
case 'd':
return 13
case 'e':
return 14
case 'f':
return 15
case 'D':
return 13
case 'E':
return 14
case 'F':
return 15
}
return 0
}
func reverse(s []uint64) {
for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
s[i], s[j] = s[j], s[i]
}
}
func main() {
reader := bufio.NewReader(os.Stdin)
str, _ := reader.ReadString('\n')
runeslice := []rune(str)
runeslice = runeslice[2:]
runeslice = runeslice[:len(runeslice) - 2]
var uintSlice []uint64
for _, v := range runeslice {
uintSlice = append(uintSlice, getValue(v))
}
reverse(uintSlice)
var result uint64
for i := 0; i < len(uintSlice); i++ {
result += uintSlice[i] * pow16(i)
}
print(result)
}
func pow16(n int) uint64 {
var result uint64
result = 1
for i := 0; i < n; i++ {
result *= 16
}
return result
}
网友评论