結果

問題 No.113 宝探し
ユーザー YOSHIYOSHI
提出日時 2021-02-28 00:08:35
言語 Java21
(openjdk 21)
結果
AC  
実行時間 51 ms / 5,000 ms
コード長 632 bytes
コンパイル時間 2,939 ms
コンパイル使用メモリ 75,008 KB
実行使用メモリ 50,564 KB
最終ジャッジ日時 2024-04-10 15:51:52
合計ジャッジ時間 5,290 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 49 ms
50,208 KB
testcase_01 AC 50 ms
50,188 KB
testcase_02 AC 50 ms
50,364 KB
testcase_03 AC 50 ms
50,472 KB
testcase_04 AC 49 ms
50,080 KB
testcase_05 AC 47 ms
49,848 KB
testcase_06 AC 50 ms
50,052 KB
testcase_07 AC 50 ms
50,328 KB
testcase_08 AC 48 ms
50,248 KB
testcase_09 AC 51 ms
50,424 KB
testcase_10 AC 48 ms
50,468 KB
testcase_11 AC 49 ms
49,932 KB
testcase_12 AC 50 ms
50,084 KB
testcase_13 AC 50 ms
50,240 KB
testcase_14 AC 49 ms
49,956 KB
testcase_15 AC 48 ms
50,088 KB
testcase_16 AC 48 ms
50,208 KB
testcase_17 AC 50 ms
50,564 KB
testcase_18 AC 49 ms
50,420 KB
testcase_19 AC 49 ms
50,348 KB
testcase_20 AC 50 ms
50,324 KB
testcase_21 AC 49 ms
50,320 KB
testcase_22 AC 49 ms
50,080 KB
testcase_23 AC 50 ms
50,128 KB
testcase_24 AC 50 ms
50,396 KB
testcase_25 AC 51 ms
50,348 KB
testcase_26 AC 51 ms
50,220 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class No00000113_Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		String[] arr = br.readLine().split("");
		int x = 0;
		int y = 0;
		for(String s : arr) {
			switch(s) {
			case "N":
				y++;
				break;
			case "E":
				x++;
				break;
			case "W":
				x--;
				break;
			case "S":
				y--;
				break;
			default:
				break;
			}
		}

		System.out.println(Math.sqrt(Math.abs(x) * Math.abs(x) + Math.abs(y) * Math.abs(y)));

	}

}
0