結果

問題 No.113 宝探し
ユーザー TwinkleStar74TwinkleStar74
提出日時 2017-09-30 22:55:18
言語 Java21
(openjdk 21)
結果
AC  
実行時間 55 ms / 5,000 ms
コード長 737 bytes
コンパイル時間 3,283 ms
コンパイル使用メモリ 74,064 KB
実行使用メモリ 37,272 KB
最終ジャッジ日時 2024-04-28 08:00:05
合計ジャッジ時間 5,694 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 53 ms
36,976 KB
testcase_01 AC 55 ms
37,052 KB
testcase_02 AC 53 ms
37,020 KB
testcase_03 AC 53 ms
36,904 KB
testcase_04 AC 52 ms
36,956 KB
testcase_05 AC 53 ms
37,140 KB
testcase_06 AC 52 ms
37,272 KB
testcase_07 AC 55 ms
37,060 KB
testcase_08 AC 54 ms
36,756 KB
testcase_09 AC 53 ms
37,032 KB
testcase_10 AC 53 ms
37,096 KB
testcase_11 AC 52 ms
37,052 KB
testcase_12 AC 54 ms
36,952 KB
testcase_13 AC 55 ms
36,724 KB
testcase_14 AC 52 ms
37,016 KB
testcase_15 AC 53 ms
36,952 KB
testcase_16 AC 52 ms
37,100 KB
testcase_17 AC 53 ms
36,960 KB
testcase_18 AC 52 ms
37,008 KB
testcase_19 AC 51 ms
36,880 KB
testcase_20 AC 52 ms
37,016 KB
testcase_21 AC 53 ms
37,000 KB
testcase_22 AC 50 ms
37,024 KB
testcase_23 AC 52 ms
36,924 KB
testcase_24 AC 55 ms
36,712 KB
testcase_25 AC 53 ms
37,112 KB
testcase_26 AC 53 ms
37,076 KB
権限があれば一括ダウンロードができます

ソースコード

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