結果

問題 No.113 宝探し
ユーザー fkwnw3_1243fkwnw3_1243
提出日時 2017-04-29 06:59:39
言語 Java21
(openjdk 21)
結果
AC  
実行時間 43 ms / 5,000 ms
コード長 830 bytes
コンパイル時間 1,772 ms
コンパイル使用メモリ 71,996 KB
実行使用メモリ 49,640 KB
最終ジャッジ日時 2023-08-10 14:54:23
合計ジャッジ時間 4,215 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 42 ms
49,136 KB
testcase_01 AC 42 ms
49,640 KB
testcase_02 AC 41 ms
49,528 KB
testcase_03 AC 42 ms
49,256 KB
testcase_04 AC 43 ms
49,196 KB
testcase_05 AC 41 ms
49,204 KB
testcase_06 AC 42 ms
49,224 KB
testcase_07 AC 42 ms
49,216 KB
testcase_08 AC 41 ms
49,256 KB
testcase_09 AC 42 ms
49,348 KB
testcase_10 AC 42 ms
49,388 KB
testcase_11 AC 42 ms
49,236 KB
testcase_12 AC 41 ms
49,344 KB
testcase_13 AC 41 ms
49,224 KB
testcase_14 AC 41 ms
49,184 KB
testcase_15 AC 41 ms
49,192 KB
testcase_16 AC 42 ms
49,220 KB
testcase_17 AC 42 ms
49,012 KB
testcase_18 AC 43 ms
49,200 KB
testcase_19 AC 42 ms
49,292 KB
testcase_20 AC 41 ms
49,392 KB
testcase_21 AC 42 ms
49,212 KB
testcase_22 AC 41 ms
49,348 KB
testcase_23 AC 41 ms
49,008 KB
testcase_24 AC 42 ms
49,412 KB
testcase_25 AC 41 ms
49,292 KB
testcase_26 AC 42 ms
49,124 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':
                    x -= 1;
                    break;
                case 'S':
                    y -= 1;
                    break;

            }
        }

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