結果

問題 No.113 宝探し
ユーザー abcabc
提出日時 2016-11-05 02:56:17
言語 Java21
(openjdk 21)
結果
AC  
実行時間 110 ms / 5,000 ms
コード長 764 bytes
コンパイル時間 1,650 ms
コンパイル使用メモリ 74,608 KB
実行使用メモリ 41,280 KB
最終ジャッジ日時 2024-04-28 07:51:56
合計ジャッジ時間 5,272 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 87 ms
39,636 KB
testcase_01 AC 98 ms
40,392 KB
testcase_02 AC 102 ms
41,120 KB
testcase_03 AC 99 ms
40,040 KB
testcase_04 AC 106 ms
41,136 KB
testcase_05 AC 97 ms
40,256 KB
testcase_06 AC 107 ms
40,888 KB
testcase_07 AC 101 ms
39,964 KB
testcase_08 AC 92 ms
40,136 KB
testcase_09 AC 106 ms
41,280 KB
testcase_10 AC 97 ms
39,972 KB
testcase_11 AC 88 ms
39,984 KB
testcase_12 AC 103 ms
40,216 KB
testcase_13 AC 107 ms
41,212 KB
testcase_14 AC 90 ms
39,524 KB
testcase_15 AC 110 ms
41,064 KB
testcase_16 AC 100 ms
40,404 KB
testcase_17 AC 91 ms
39,996 KB
testcase_18 AC 104 ms
41,124 KB
testcase_19 AC 106 ms
41,108 KB
testcase_20 AC 97 ms
40,124 KB
testcase_21 AC 95 ms
40,312 KB
testcase_22 AC 95 ms
40,224 KB
testcase_23 AC 95 ms
40,276 KB
testcase_24 AC 95 ms
40,276 KB
testcase_25 AC 107 ms
41,032 KB
testcase_26 AC 93 ms
39,768 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner sc = new Scanner(System.in);

        String direction = sc.next();

        int x = 0;
        int y = 0;

        for (int i = 0; i < direction.length(); i++) {

            switch (direction.charAt(i)) {
                case 'N' :
                    y++;
                    break;
                case 'E' :
                    x++;
                    break;
                case 'W' :
                    x--;
                    break;
                case 'S' :
                    y--;
                    break;
            }

        }

        double distance = Math.sqrt((x * x) + (y * y));

        System.out.println(distance);

    }

}
0