結果

問題 No.113 宝探し
ユーザー Hiroaki KonoHiroaki Kono
提出日時 2017-10-26 23:41:02
言語 Java21
(openjdk 21)
結果
AC  
実行時間 112 ms / 5,000 ms
コード長 708 bytes
コンパイル時間 2,898 ms
コンパイル使用メモリ 74,932 KB
実行使用メモリ 41,684 KB
最終ジャッジ日時 2024-04-28 08:02:06
合計ジャッジ時間 6,572 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 109 ms
41,252 KB
testcase_01 AC 110 ms
41,132 KB
testcase_02 AC 98 ms
40,312 KB
testcase_03 AC 98 ms
40,124 KB
testcase_04 AC 95 ms
40,276 KB
testcase_05 AC 97 ms
40,312 KB
testcase_06 AC 108 ms
41,004 KB
testcase_07 AC 111 ms
41,260 KB
testcase_08 AC 98 ms
40,004 KB
testcase_09 AC 110 ms
41,108 KB
testcase_10 AC 102 ms
40,624 KB
testcase_11 AC 110 ms
41,208 KB
testcase_12 AC 109 ms
41,148 KB
testcase_13 AC 100 ms
40,232 KB
testcase_14 AC 98 ms
40,260 KB
testcase_15 AC 106 ms
41,184 KB
testcase_16 AC 109 ms
41,520 KB
testcase_17 AC 95 ms
40,148 KB
testcase_18 AC 107 ms
41,256 KB
testcase_19 AC 112 ms
41,684 KB
testcase_20 AC 106 ms
40,000 KB
testcase_21 AC 94 ms
40,312 KB
testcase_22 AC 94 ms
40,132 KB
testcase_23 AC 105 ms
41,024 KB
testcase_24 AC 100 ms
40,396 KB
testcase_25 AC 110 ms
41,232 KB
testcase_26 AC 109 ms
41,164 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No113 {

    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        String guide = s.next();
        char[] c = guide.toCharArray();
        int east = 0;
        int north = 0;
        for (int i = 0; i < c.length; i++) {
            if (c[i] == 'N') {
                north++;
            } else if (c[i] == 'E') {
                east++;
            } else if (c[i] == 'S') {
                north--;
            } else if (c[i] == 'W') {
                east--;
            }
        }
        east = Math.abs(east);
        north = Math.abs(north);
        System.out.println(Math.sqrt(east * east + north * north));
    }
}
0