結果
問題 |
No.113 宝探し
|
ユーザー |
|
提出日時 | 2015-03-07 09:24:50 |
言語 | Go (1.23.4) |
結果 |
AC
|
実行時間 | 2 ms / 5,000 ms |
コード長 | 652 bytes |
コンパイル時間 | 11,312 ms |
コンパイル使用メモリ | 223,476 KB |
実行使用メモリ | 6,820 KB |
最終ジャッジ日時 | 2024-11-16 20:41:07 |
合計ジャッジ時間 | 12,203 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge3 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 23 |
ソースコード
package main import ( "bufio" "os" "strconv" "fmt" "math" ) var s = bufio.NewScanner(os.Stdin) func next() string { s.Split(bufio.ScanWords) 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 } func abs(a int) int { if a < 0 { return -a } return a } func main() { S := next() x := 0 y := 0 for _, c := range S { switch c{ case 'N': y++ case 'E': x++ case 'W': x-- case 'S': y-- } } fmt.Println(math.Sqrt(float64(abs(x*x+y*y)))) }