結果

問題 No.113 宝探し
ユーザー TatsuDX
提出日時 2016-09-08 23:48:41
言語 Java
(openjdk 23)
結果
AC  
実行時間 120 ms / 5,000 ms
コード長 427 bytes
コンパイル時間 3,937 ms
コンパイル使用メモリ 74,984 KB
実行使用メモリ 41,472 KB
最終ジャッジ日時 2024-11-16 21:25:29
合計ジャッジ時間 7,561 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Test {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		double x = 0, y = 0;
		char c;
		for (int i = 0; i < s.length(); i++) {
			c = s.charAt(i);
			if (c == 'W') {
				x++;
			} else if (c == 'E') {
				x--;
			} else if (c == 'N') {
				y++;
			} else {
				y--;
			}
		}
		System.out.println(Math.sqrt(x * x + y * y));
	}
}
0