// No.113 宝探し package main import ( "fmt" "math" ) func main() { var s string fmt.Scan(&s) type P struct { X float64 Y float64 } p := P{X: 0, Y: 0} for _, r := range s { switch string(r) { case "N": p.X += 1 case "S": p.X -= 1 case "E": p.Y += 1 case "W": p.Y -= 1 } } fmt.Println(math.Sqrt(math.Pow(p.X, 2) + math.Pow(p.Y, 2))) }