結果

問題 No.113 宝探し
ユーザー TwinkleStar74
提出日時 2017-09-30 22:55:18
言語 Java
(openjdk 23)
結果
AC  
実行時間 49 ms / 5,000 ms
コード長 737 bytes
コンパイル時間 2,922 ms
コンパイル使用メモリ 74,400 KB
実行使用メモリ 37,076 KB
最終ジャッジ日時 2024-11-16 21:37:37
合計ジャッジ時間 4,941 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class No113 {

	public static void main(String[] args) {
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			String str = br.readLine();
			String[] houi = new String[str.length()];
			for(int i=0; i<str.length(); i++)
				houi[i] = String.valueOf(str.charAt(i));
			int x = 0; int y = 0;
			for(int i=0; i<houi.length ;i++){
				if(houi[i].equals("N"))
					y++;
				if(houi[i].equals("S"))
					y--;
				if(houi[i].equals("E"))
					x++;
				if(houi[i].equals("W"))
					x--;
			}
			System.out.println(Math.sqrt(Math.pow(x,2)+Math.pow(y,2)));
		}catch(IOException e){
			e.getStackTrace();
		}
	}
}
0