結果

問題 No.113 宝探し
ユーザー dazydazy
提出日時 2016-09-13 04:39:28
言語 Java21
(openjdk 21)
結果
AC  
実行時間 129 ms / 5,000 ms
コード長 545 bytes
コンパイル時間 3,533 ms
コンパイル使用メモリ 74,744 KB
実行使用メモリ 41,676 KB
最終ジャッジ日時 2024-04-28 07:50:27
合計ジャッジ時間 7,827 ms
ジャッジサーバーID
(参考情報)
judge5 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 124 ms
40,772 KB
testcase_01 AC 124 ms
40,936 KB
testcase_02 AC 127 ms
40,728 KB
testcase_03 AC 127 ms
40,760 KB
testcase_04 AC 127 ms
40,980 KB
testcase_05 AC 124 ms
40,720 KB
testcase_06 AC 124 ms
41,116 KB
testcase_07 AC 109 ms
39,504 KB
testcase_08 AC 122 ms
41,020 KB
testcase_09 AC 111 ms
39,724 KB
testcase_10 AC 122 ms
40,724 KB
testcase_11 AC 124 ms
40,720 KB
testcase_12 AC 123 ms
40,752 KB
testcase_13 AC 127 ms
41,072 KB
testcase_14 AC 127 ms
40,920 KB
testcase_15 AC 123 ms
40,876 KB
testcase_16 AC 110 ms
39,724 KB
testcase_17 AC 122 ms
41,244 KB
testcase_18 AC 124 ms
40,908 KB
testcase_19 AC 123 ms
41,252 KB
testcase_20 AC 126 ms
41,676 KB
testcase_21 AC 127 ms
41,268 KB
testcase_22 AC 124 ms
40,896 KB
testcase_23 AC 122 ms
40,716 KB
testcase_24 AC 123 ms
40,848 KB
testcase_25 AC 129 ms
40,772 KB
testcase_26 AC 127 ms
41,272 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Run {
    public static void main (String arg[]) {
        Scanner scan = new Scanner(System.in);
        String S = scan.next();
        int[] c = {0, 0};
        for (int i = 0; i < S.length(); i++) {
            news(S.charAt(i), c);
        }
        System.out.println(Math.pow((c[0]*c[0] + c[1]*c[1]), 0.5));
    }

    public static void news (char x, int[] c) {
        if (x=='N') c[1]++;
        else if (x=='E') c[0]++;
        else if (x=='W') c[0]--;
        else if (x=='S') c[1]--;
    }
}
0