結果

問題 No.113 宝探し
ユーザー YamaKasaYamaKasa
提出日時 2018-04-24 22:25:55
言語 Java21
(openjdk 21)
結果
AC  
実行時間 119 ms / 5,000 ms
コード長 474 bytes
コンパイル時間 1,883 ms
コンパイル使用メモリ 74,004 KB
実行使用メモリ 41,592 KB
最終ジャッジ日時 2024-04-28 08:12:53
合計ジャッジ時間 5,575 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 96 ms
40,080 KB
testcase_01 AC 108 ms
41,184 KB
testcase_02 AC 101 ms
40,224 KB
testcase_03 AC 107 ms
41,092 KB
testcase_04 AC 107 ms
41,420 KB
testcase_05 AC 94 ms
39,620 KB
testcase_06 AC 107 ms
40,824 KB
testcase_07 AC 109 ms
41,324 KB
testcase_08 AC 106 ms
40,812 KB
testcase_09 AC 97 ms
40,004 KB
testcase_10 AC 109 ms
41,416 KB
testcase_11 AC 106 ms
41,064 KB
testcase_12 AC 112 ms
40,896 KB
testcase_13 AC 107 ms
41,272 KB
testcase_14 AC 105 ms
40,992 KB
testcase_15 AC 105 ms
41,052 KB
testcase_16 AC 107 ms
41,592 KB
testcase_17 AC 107 ms
41,388 KB
testcase_18 AC 119 ms
41,276 KB
testcase_19 AC 102 ms
41,144 KB
testcase_20 AC 109 ms
41,500 KB
testcase_21 AC 112 ms
41,404 KB
testcase_22 AC 104 ms
40,836 KB
testcase_23 AC 94 ms
40,132 KB
testcase_24 AC 109 ms
40,972 KB
testcase_25 AC 104 ms
40,080 KB
testcase_26 AC 101 ms
39,992 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String S = scan.next();
		scan.close();
		int x = 0;
		int y = 0;
		for(int i = 0; i < S.length(); i++) {
			char c = S.charAt(i);
			if(c == 'N') {
				y ++;
			}else if(c == 'E') {
				x ++;
			}else if(c == 'W') {
				x --;
			}else if(c == 'S') {
				y --;
			}
		}
		double ans = Math.sqrt(x * x + y * y);
		System.out.println(ans);
	}
}
0