結果

問題 No.113 宝探し
ユーザー Natsume-M
提出日時 2016-12-09 19:03:00
言語 Java
(openjdk 23)
結果
AC  
実行時間 118 ms / 5,000 ms
コード長 403 bytes
コンパイル時間 1,930 ms
コンパイル使用メモリ 74,128 KB
実行使用メモリ 41,436 KB
最終ジャッジ日時 2024-11-16 21:29:26
合計ジャッジ時間 5,643 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
class y113 {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		double x = 0, y = 0;
		for (int i=0; i<s.length(); i++) {
			if	(s.charAt(i) == 'N')	y--;
			else if	(s.charAt(i) == 'E')	x++;
			else if	(s.charAt(i) == 'W')	x--;
			else if	(s.charAt(i) == 'S')	y++;
		}
		System.out.println(Math.hypot(x, y));
		sc.close();
	}
}
0