結果

問題 No.113 宝探し
コンテスト
ユーザー ゆうP
提出日時 2024-03-30 15:03:06
言語 Go
(1.27.0 + ACL)
コンパイル:
/usr/bin/go_c
実行:
./Main
結果
AC  
実行時間 1 ms / 5,000 ms
+ 212µs
コード長 378 bytes
記録
記録タグの例:
初AC ショートコード 純ショートコード 純主流ショートコード 最速実行時間
コンパイル時間 9,513 ms
コンパイル使用メモリ 258,392 KB
実行使用メモリ 6,400 KB
最終ジャッジ日時 2026-09-06 21:22:16
合計ジャッジ時間 11,597 ms
ジャッジサーバーID
(参考情報)
judge1_0 / judge3_0
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #
raw source code

// 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)))
}
0