結果

問題 No.113 宝探し
ユーザー ffmm00ffmm00
提出日時 2015-06-15 17:15:44
言語 Java21
(openjdk 21)
結果
AC  
実行時間 139 ms / 5,000 ms
コード長 491 bytes
コンパイル時間 3,570 ms
コンパイル使用メモリ 75,264 KB
実行使用メモリ 41,728 KB
最終ジャッジ日時 2024-04-28 07:26:22
合計ジャッジ時間 7,844 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
41,064 KB
testcase_01 AC 134 ms
41,728 KB
testcase_02 AC 128 ms
41,252 KB
testcase_03 AC 124 ms
40,996 KB
testcase_04 AC 131 ms
41,320 KB
testcase_05 AC 129 ms
41,108 KB
testcase_06 AC 132 ms
40,976 KB
testcase_07 AC 130 ms
41,452 KB
testcase_08 AC 133 ms
41,404 KB
testcase_09 AC 129 ms
41,296 KB
testcase_10 AC 114 ms
39,820 KB
testcase_11 AC 132 ms
41,260 KB
testcase_12 AC 136 ms
41,352 KB
testcase_13 AC 131 ms
41,408 KB
testcase_14 AC 123 ms
41,056 KB
testcase_15 AC 129 ms
41,532 KB
testcase_16 AC 124 ms
41,152 KB
testcase_17 AC 129 ms
41,064 KB
testcase_18 AC 127 ms
41,148 KB
testcase_19 AC 131 ms
41,604 KB
testcase_20 AC 132 ms
41,336 KB
testcase_21 AC 126 ms
40,992 KB
testcase_22 AC 124 ms
41,104 KB
testcase_23 AC 129 ms
41,556 KB
testcase_24 AC 114 ms
40,044 KB
testcase_25 AC 119 ms
39,976 KB
testcase_26 AC 139 ms
41,484 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class N113 {

	public static void main(String[] args) {

		Scanner sca = new Scanner(System.in);

		char[] d = sca.next().toCharArray();
		double A = 0;
		double x = 0;
		double y = 0;

		for (int i = 0; i < d.length; i++) {
			switch (d[i]) {
			case 'N':
				y++;
				break;
			case 'E':
				x++;
				break;
			case 'W':
				x--;
				break;
			case 'S':
				y--;
				break;
			}
		}

		A = Math.sqrt(x * x + y * y);

		System.out.printf("%.6f", A);

	}

}
0