結果

問題 No.113 宝探し
ユーザー l1267976
提出日時 2017-03-19 15:50:24
言語 Java
(openjdk 23)
結果
AC  
実行時間 134 ms / 5,000 ms
コード長 740 bytes
コンパイル時間 3,535 ms
コンパイル使用メモリ 74,892 KB
実行使用メモリ 54,236 KB
最終ジャッジ日時 2024-11-16 21:31:59
合計ジャッジ時間 8,103 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class No113 {

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

        int x = 0;
        int y = 0;

        for (int i = 0; i < s.length(); i++) {
            char c = s.charAt(i);

            switch (c) {
            case 'N':
                y++;
                break;
            case 'E':
                x--;
                break;
            case 'W':
                x++;
                break;
            case 'S':
                y--;
                break;
            }
        }

        double result = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));

        System.out.println(result);

        sc.close();
    }

}
0