結果

問題 No.113 宝探し
ユーザー fkwnw3_1243fkwnw3_1243
提出日時 2017-04-29 06:58:48
言語 Java19
(openjdk 21)
結果
WA  
実行時間 -
コード長 829 bytes
コンパイル時間 3,095 ms
コンパイル使用メモリ 71,676 KB
実行使用メモリ 51,416 KB
最終ジャッジ日時 2023-10-11 20:14:35
合計ジャッジ時間 5,544 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 44 ms
49,228 KB
testcase_02 AC 44 ms
49,424 KB
testcase_03 AC 44 ms
49,620 KB
testcase_04 WA -
testcase_05 AC 43 ms
49,232 KB
testcase_06 AC 44 ms
49,252 KB
testcase_07 AC 43 ms
49,220 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 43 ms
49,256 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 44 ms
49,156 KB
testcase_18 AC 43 ms
49,296 KB
testcase_19 AC 45 ms
49,356 KB
testcase_20 AC 44 ms
49,288 KB
testcase_21 AC 43 ms
49,356 KB
testcase_22 AC 44 ms
49,344 KB
testcase_23 AC 43 ms
49,208 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 44 ms
49,256 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        String S = reader.readLine();
        int x = 0;
        int y = 0;
        for (int i = 0; i < S.length(); i++) {
            switch (S.charAt(i)) {
                case 'N':
                    y += 1;
                    break;
                case 'E':
                    x += 1;
                    break;
                case 'W':
                    y -= 1;
                    break;
                case 'S':
                    x -= 1;
                    break;

            }
        }

        System.out.println(Math.sqrt(x*x + y*y));
    }
}
0