結果

問題 No.113 宝探し
ユーザー matsuyoshi30matsuyoshi30
提出日時 2016-08-16 22:51:58
言語 Java21
(openjdk 21)
結果
AC  
実行時間 134 ms / 5,000 ms
コード長 781 bytes
コンパイル時間 2,142 ms
コンパイル使用メモリ 75,156 KB
実行使用メモリ 54,308 KB
最終ジャッジ日時 2024-04-28 07:46:20
合計ジャッジ時間 6,653 ms
ジャッジサーバーID
(参考情報)
judge2 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 123 ms
53,844 KB
testcase_01 AC 126 ms
53,828 KB
testcase_02 AC 129 ms
54,232 KB
testcase_03 AC 128 ms
54,308 KB
testcase_04 AC 130 ms
53,748 KB
testcase_05 AC 128 ms
53,836 KB
testcase_06 AC 129 ms
54,192 KB
testcase_07 AC 128 ms
54,080 KB
testcase_08 AC 131 ms
54,056 KB
testcase_09 AC 129 ms
53,764 KB
testcase_10 AC 133 ms
53,920 KB
testcase_11 AC 127 ms
54,128 KB
testcase_12 AC 127 ms
54,116 KB
testcase_13 AC 130 ms
54,032 KB
testcase_14 AC 127 ms
53,800 KB
testcase_15 AC 129 ms
53,808 KB
testcase_16 AC 131 ms
53,900 KB
testcase_17 AC 129 ms
53,772 KB
testcase_18 AC 128 ms
54,028 KB
testcase_19 AC 128 ms
54,124 KB
testcase_20 AC 131 ms
54,148 KB
testcase_21 AC 134 ms
54,096 KB
testcase_22 AC 128 ms
54,116 KB
testcase_23 AC 127 ms
53,840 KB
testcase_24 AC 128 ms
53,952 KB
testcase_25 AC 130 ms
54,248 KB
testcase_26 AC 129 ms
54,088 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;

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

        int x = 0, y = 0;
        for(int i=0; i<s.length(); i++) {
            switch(s.charAt(i)) {
            case 'N':
                y++;
                break;
            case 'W':
                x--;
                break;
            case 'S':
                y--;
                break;
            case 'E':
                x++;
                break;
            default:
                break;
            }
        }

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

        System.out.println(l);

        in.close();
    }
}
0