結果

問題 No.113 宝探し
ユーザー yagi2yagi2
提出日時 2017-04-25 11:06:28
言語 Java21
(openjdk 21)
結果
AC  
実行時間 116 ms / 5,000 ms
コード長 502 bytes
コンパイル時間 2,219 ms
コンパイル使用メモリ 79,428 KB
実行使用メモリ 41,616 KB
最終ジャッジ日時 2024-04-28 07:55:46
合計ジャッジ時間 5,273 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 94 ms
40,292 KB
testcase_01 AC 101 ms
41,196 KB
testcase_02 AC 94 ms
40,256 KB
testcase_03 AC 103 ms
41,116 KB
testcase_04 AC 111 ms
40,124 KB
testcase_05 AC 104 ms
40,864 KB
testcase_06 AC 98 ms
40,836 KB
testcase_07 AC 89 ms
40,404 KB
testcase_08 AC 101 ms
40,860 KB
testcase_09 AC 104 ms
40,984 KB
testcase_10 AC 101 ms
40,980 KB
testcase_11 AC 103 ms
40,928 KB
testcase_12 AC 103 ms
41,144 KB
testcase_13 AC 89 ms
40,264 KB
testcase_14 AC 98 ms
40,836 KB
testcase_15 AC 106 ms
41,092 KB
testcase_16 AC 114 ms
40,924 KB
testcase_17 AC 102 ms
41,032 KB
testcase_18 AC 90 ms
40,008 KB
testcase_19 AC 103 ms
40,956 KB
testcase_20 AC 103 ms
40,904 KB
testcase_21 AC 103 ms
41,052 KB
testcase_22 AC 108 ms
40,964 KB
testcase_23 AC 93 ms
40,032 KB
testcase_24 AC 109 ms
41,048 KB
testcase_25 AC 102 ms
41,252 KB
testcase_26 AC 116 ms
41,616 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        String[] S = sc.next().split("");

        int T = 0;
        int Y = 0;
        for(String s : S) {
            if ("N".equals(s)) T++;
            if ("E".equals(s)) Y++;
            if ("W".equals(s)) Y--;
            if ("S".equals(s)) T--;
        }

        System.out.println(Math.sqrt(Math.pow(Math.abs(T), 2) + Math.pow(Math.abs(Y), 2)));
    }
}
0