結果

問題 No.113 宝探し
ユーザー Tsukasa_TypeTsukasa_Type
提出日時 2018-02-09 19:57:35
言語 Java21
(openjdk 21)
結果
AC  
実行時間 117 ms / 5,000 ms
コード長 428 bytes
コンパイル時間 1,765 ms
コンパイル使用メモリ 74,996 KB
実行使用メモリ 41,480 KB
最終ジャッジ日時 2024-04-28 08:07:16
合計ジャッジ時間 5,481 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 98 ms
40,364 KB
testcase_01 AC 111 ms
41,260 KB
testcase_02 AC 103 ms
40,788 KB
testcase_03 AC 117 ms
41,392 KB
testcase_04 AC 104 ms
41,236 KB
testcase_05 AC 105 ms
41,080 KB
testcase_06 AC 109 ms
41,280 KB
testcase_07 AC 108 ms
41,024 KB
testcase_08 AC 106 ms
41,392 KB
testcase_09 AC 103 ms
41,256 KB
testcase_10 AC 104 ms
41,428 KB
testcase_11 AC 115 ms
41,204 KB
testcase_12 AC 96 ms
40,404 KB
testcase_13 AC 112 ms
41,480 KB
testcase_14 AC 107 ms
41,108 KB
testcase_15 AC 104 ms
40,860 KB
testcase_16 AC 106 ms
40,808 KB
testcase_17 AC 105 ms
41,404 KB
testcase_18 AC 101 ms
41,340 KB
testcase_19 AC 101 ms
40,696 KB
testcase_20 AC 94 ms
39,872 KB
testcase_21 AC 107 ms
41,456 KB
testcase_22 AC 105 ms
40,980 KB
testcase_23 AC 103 ms
40,868 KB
testcase_24 AC 105 ms
41,208 KB
testcase_25 AC 100 ms
40,384 KB
testcase_26 AC 94 ms
39,920 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

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