結果

問題 No.113 宝探し
ユーザー TatsuDXTatsuDX
提出日時 2016-09-08 23:48:41
言語 Java21
(openjdk 21)
結果
AC  
実行時間 128 ms / 5,000 ms
コード長 427 bytes
コンパイル時間 3,428 ms
コンパイル使用メモリ 75,156 KB
実行使用メモリ 41,436 KB
最終ジャッジ日時 2024-04-28 07:49:36
合計ジャッジ時間 7,833 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
40,716 KB
testcase_01 AC 127 ms
40,840 KB
testcase_02 AC 126 ms
41,220 KB
testcase_03 AC 127 ms
41,168 KB
testcase_04 AC 126 ms
40,976 KB
testcase_05 AC 127 ms
41,144 KB
testcase_06 AC 125 ms
40,612 KB
testcase_07 AC 126 ms
40,880 KB
testcase_08 AC 126 ms
41,432 KB
testcase_09 AC 127 ms
41,216 KB
testcase_10 AC 125 ms
41,436 KB
testcase_11 AC 125 ms
41,016 KB
testcase_12 AC 128 ms
40,748 KB
testcase_13 AC 112 ms
39,624 KB
testcase_14 AC 125 ms
41,172 KB
testcase_15 AC 124 ms
40,712 KB
testcase_16 AC 124 ms
41,072 KB
testcase_17 AC 125 ms
41,036 KB
testcase_18 AC 125 ms
41,000 KB
testcase_19 AC 126 ms
40,904 KB
testcase_20 AC 125 ms
41,204 KB
testcase_21 AC 126 ms
41,108 KB
testcase_22 AC 112 ms
39,504 KB
testcase_23 AC 125 ms
40,748 KB
testcase_24 AC 114 ms
40,848 KB
testcase_25 AC 122 ms
40,644 KB
testcase_26 AC 125 ms
41,304 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Test {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		String s = sc.next();
		double x = 0, y = 0;
		char c;
		for (int i = 0; i < s.length(); i++) {
			c = s.charAt(i);
			if (c == 'W') {
				x++;
			} else if (c == 'E') {
				x--;
			} else if (c == 'N') {
				y++;
			} else {
				y--;
			}
		}
		System.out.println(Math.sqrt(x * x + y * y));
	}
}
0