結果

問題 No.113 宝探し
ユーザー spacia
提出日時 2016-01-02 08:48:09
言語 Java
(openjdk 23)
結果
AC  
実行時間 51 ms / 5,000 ms
コード長 575 bytes
コンパイル時間 2,277 ms
コンパイル使用メモリ 75,896 KB
実行使用メモリ 37,176 KB
最終ジャッジ日時 2024-11-16 21:05:56
合計ジャッジ時間 3,985 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.*;
import java.util.*;

class Main113 {
	
	public static void out (Object o) {
		System.out.println(o);
	}
		
	public static void main (String[] args) throws IOException {
		BufferedReader br = 
			new BufferedReader(new InputStreamReader(System.in));
		
		String s = br.readLine();
		int x = 0 , y = 0;
		for (int i = 0; i < s.length(); i++) {
			char c = s.charAt(i);
			if (c == 'N')
				y--;
			else if (c == 'E')
				x++;
			else if (c == 'W')
				x--;
			else
				y++;
		}
		
		x = Math.abs(x);
		y = Math.abs(y);
		
		out(Math.sqrt(x * x + y * y));
	}
}
0