結果

問題 No.113 宝探し
ユーザー ohagi_1182ohagi_1182
提出日時 2017-10-20 17:35:25
言語 Java21
(openjdk 21)
結果
AC  
実行時間 118 ms / 5,000 ms
コード長 461 bytes
コンパイル時間 2,100 ms
コンパイル使用メモリ 74,508 KB
実行使用メモリ 41,468 KB
最終ジャッジ日時 2024-04-28 08:01:23
合計ジャッジ時間 5,638 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 102 ms
41,032 KB
testcase_01 AC 94 ms
39,968 KB
testcase_02 AC 102 ms
40,024 KB
testcase_03 AC 107 ms
41,464 KB
testcase_04 AC 99 ms
41,048 KB
testcase_05 AC 89 ms
40,092 KB
testcase_06 AC 101 ms
40,924 KB
testcase_07 AC 103 ms
40,996 KB
testcase_08 AC 94 ms
39,940 KB
testcase_09 AC 103 ms
41,192 KB
testcase_10 AC 104 ms
41,008 KB
testcase_11 AC 104 ms
41,064 KB
testcase_12 AC 105 ms
41,320 KB
testcase_13 AC 100 ms
40,924 KB
testcase_14 AC 101 ms
40,852 KB
testcase_15 AC 101 ms
40,684 KB
testcase_16 AC 118 ms
41,468 KB
testcase_17 AC 102 ms
40,972 KB
testcase_18 AC 102 ms
41,348 KB
testcase_19 AC 85 ms
39,784 KB
testcase_20 AC 104 ms
40,924 KB
testcase_21 AC 92 ms
40,060 KB
testcase_22 AC 102 ms
40,768 KB
testcase_23 AC 100 ms
40,856 KB
testcase_24 AC 100 ms
41,116 KB
testcase_25 AC 107 ms
41,112 KB
testcase_26 AC 89 ms
39,864 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		int n = s.length();
		int x = 0, y = 0;
		for(int i = 0 ; i < n ; i++) {
			if(s.charAt(i) == 'N') {
				y++;
			} else if(s.charAt(i) == 'S') {
				y--;
			} else if(s.charAt(i) == 'E') {
				x++;
			} else {
				x--;
			}
		}
		System.out.printf("%.5f\n", Math.pow(Math.abs(x * x + y * y), 0.5));
 	}
}

0