結果

問題 No.113 宝探し
ユーザー htensaihtensai
提出日時 2019-12-05 15:04:17
言語 Java21
(openjdk 21)
結果
AC  
実行時間 111 ms / 5,000 ms
コード長 474 bytes
コンパイル時間 1,787 ms
コンパイル使用メモリ 74,632 KB
実行使用メモリ 41,576 KB
最終ジャッジ日時 2024-04-28 08:34:33
合計ジャッジ時間 5,566 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
41,240 KB
testcase_01 AC 108 ms
41,540 KB
testcase_02 AC 106 ms
41,028 KB
testcase_03 AC 99 ms
41,556 KB
testcase_04 AC 100 ms
41,148 KB
testcase_05 AC 97 ms
40,124 KB
testcase_06 AC 97 ms
40,264 KB
testcase_07 AC 96 ms
40,492 KB
testcase_08 AC 98 ms
40,084 KB
testcase_09 AC 105 ms
41,072 KB
testcase_10 AC 107 ms
41,488 KB
testcase_11 AC 99 ms
41,148 KB
testcase_12 AC 98 ms
41,200 KB
testcase_13 AC 105 ms
41,452 KB
testcase_14 AC 106 ms
41,256 KB
testcase_15 AC 99 ms
40,252 KB
testcase_16 AC 108 ms
41,532 KB
testcase_17 AC 111 ms
41,408 KB
testcase_18 AC 98 ms
40,276 KB
testcase_19 AC 101 ms
41,552 KB
testcase_20 AC 97 ms
40,392 KB
testcase_21 AC 104 ms
41,004 KB
testcase_22 AC 97 ms
40,404 KB
testcase_23 AC 99 ms
41,576 KB
testcase_24 AC 99 ms
41,144 KB
testcase_25 AC 108 ms
40,892 KB
testcase_26 AC 99 ms
40,508 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] arr = sc.next().toCharArray();
	    int x = 0;
	    int y = 0;
	    for (char c : arr) {
	        if (c == 'N') {
	            y++;
	        } else if (c == 'S') {
	            y--;
	        } else if (c == 'E') {
	            x++;
	        } else {
	            x--;
	        }
	    }
		System.out.println(Math.sqrt(x * x + y * y));
   }
}

0