結果

問題 No.113 宝探し
ユーザー koukonkokoukonko
提出日時 2015-12-11 22:06:40
言語 Java21
(openjdk 21)
結果
AC  
実行時間 53 ms / 5,000 ms
コード長 782 bytes
コンパイル時間 2,091 ms
コンパイル使用メモリ 73,592 KB
実行使用メモリ 37,160 KB
最終ジャッジ日時 2024-04-28 07:32:02
合計ジャッジ時間 4,667 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 46 ms
36,828 KB
testcase_01 AC 50 ms
36,784 KB
testcase_02 AC 49 ms
36,912 KB
testcase_03 AC 45 ms
36,876 KB
testcase_04 AC 43 ms
37,072 KB
testcase_05 AC 45 ms
36,868 KB
testcase_06 AC 44 ms
36,912 KB
testcase_07 AC 43 ms
37,024 KB
testcase_08 AC 44 ms
37,072 KB
testcase_09 AC 45 ms
37,032 KB
testcase_10 AC 47 ms
36,952 KB
testcase_11 AC 47 ms
36,760 KB
testcase_12 AC 45 ms
37,040 KB
testcase_13 AC 45 ms
36,764 KB
testcase_14 AC 46 ms
37,072 KB
testcase_15 AC 46 ms
36,636 KB
testcase_16 AC 46 ms
36,768 KB
testcase_17 AC 47 ms
36,636 KB
testcase_18 AC 47 ms
37,160 KB
testcase_19 AC 50 ms
36,848 KB
testcase_20 AC 53 ms
36,904 KB
testcase_21 AC 46 ms
36,892 KB
testcase_22 AC 46 ms
36,956 KB
testcase_23 AC 44 ms
37,072 KB
testcase_24 AC 45 ms
36,748 KB
testcase_25 AC 45 ms
36,644 KB
testcase_26 AC 47 ms
37,064 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

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

public class Main {
	public static void main(String[] args) {
		BufferedReader buff = new BufferedReader(new InputStreamReader(System.in));

		try {
			String line = buff.readLine();
			int x = 0, y = 0;

			for (int i = 0; i < line.length(); ++i) {
				if (line.charAt(i) == 'N') {
					++y;
				} else if (line.charAt(i) == 'E') {
					++x;
				} else if (line.charAt(i) == 'S') {
					--y;
				} else {
					--x;
				}
			}

			double ans = Math.sqrt((Math.pow(x, 2) + Math.pow(y, 2)));

			System.out.println(ans);

		} catch (NumberFormatException e) {
			e.getStackTrace();
		} catch (IOException e) {
			e.getStackTrace();
		} catch (Exception e) {
			e.getStackTrace();
		}
	}
}
0