結果

問題 No.113 宝探し
ユーザー ぴろずぴろず
提出日時 2014-12-28 23:24:48
言語 Java21
(openjdk 21)
結果
AC  
実行時間 117 ms / 5,000 ms
コード長 443 bytes
コンパイル時間 2,313 ms
コンパイル使用メモリ 71,872 KB
実行使用メモリ 57,728 KB
最終ジャッジ日時 2023-08-10 14:03:08
合計ジャッジ時間 6,601 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 112 ms
55,752 KB
testcase_01 AC 113 ms
55,596 KB
testcase_02 AC 114 ms
55,920 KB
testcase_03 AC 115 ms
57,252 KB
testcase_04 AC 114 ms
55,884 KB
testcase_05 AC 114 ms
55,808 KB
testcase_06 AC 116 ms
55,556 KB
testcase_07 AC 114 ms
56,076 KB
testcase_08 AC 115 ms
55,876 KB
testcase_09 AC 115 ms
57,728 KB
testcase_10 AC 114 ms
55,788 KB
testcase_11 AC 113 ms
55,840 KB
testcase_12 AC 113 ms
55,556 KB
testcase_13 AC 112 ms
55,864 KB
testcase_14 AC 114 ms
54,012 KB
testcase_15 AC 112 ms
55,852 KB
testcase_16 AC 112 ms
55,712 KB
testcase_17 AC 114 ms
55,492 KB
testcase_18 AC 113 ms
55,940 KB
testcase_19 AC 115 ms
55,940 KB
testcase_20 AC 115 ms
56,136 KB
testcase_21 AC 115 ms
55,568 KB
testcase_22 AC 117 ms
55,684 KB
testcase_23 AC 113 ms
56,228 KB
testcase_24 AC 113 ms
55,712 KB
testcase_25 AC 115 ms
55,860 KB
testcase_26 AC 114 ms
55,684 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package no113;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = 0, y = 0;
		char[] s = sc.next().toCharArray();
		for(int i=0;i<s.length;i++) {
			switch (s[i]) {
			case 'N':
				y++;
				break;
			case 'S':
				y--;
				break;
			case 'E':
				x++;
				break;
			case 'W':
				x--;
				break;
			}
		}
		System.out.println(Math.sqrt(x*x+y*y));
	}

}
0