結果

問題 No.113 宝探し
ユーザー atkrymatkrym
提出日時 2016-10-25 21:12:10
言語 Java21
(openjdk 21)
結果
AC  
実行時間 134 ms / 5,000 ms
コード長 531 bytes
コンパイル時間 2,074 ms
コンパイル使用メモリ 74,096 KB
実行使用メモリ 42,420 KB
最終ジャッジ日時 2024-04-28 07:51:40
合計ジャッジ時間 6,417 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 127 ms
41,016 KB
testcase_01 AC 129 ms
41,272 KB
testcase_02 AC 123 ms
40,972 KB
testcase_03 AC 125 ms
41,008 KB
testcase_04 AC 127 ms
41,396 KB
testcase_05 AC 113 ms
39,868 KB
testcase_06 AC 127 ms
40,608 KB
testcase_07 AC 124 ms
40,596 KB
testcase_08 AC 126 ms
41,288 KB
testcase_09 AC 127 ms
40,724 KB
testcase_10 AC 127 ms
41,136 KB
testcase_11 AC 131 ms
42,420 KB
testcase_12 AC 128 ms
40,776 KB
testcase_13 AC 130 ms
41,032 KB
testcase_14 AC 128 ms
41,264 KB
testcase_15 AC 128 ms
40,984 KB
testcase_16 AC 112 ms
40,140 KB
testcase_17 AC 124 ms
41,240 KB
testcase_18 AC 125 ms
40,628 KB
testcase_19 AC 126 ms
40,892 KB
testcase_20 AC 127 ms
41,176 KB
testcase_21 AC 125 ms
40,932 KB
testcase_22 AC 127 ms
40,848 KB
testcase_23 AC 125 ms
40,640 KB
testcase_24 AC 134 ms
40,808 KB
testcase_25 AC 129 ms
40,868 KB
testcase_26 AC 128 ms
41,504 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    private static Scanner sc = new Scanner(System.in);
    public static void main(String[] args) throws Exception {
        int x = 0;
        int y = 0;
        String s = sc.next();
        for (int i = 0;i < s.length();i++) {
            if (s.charAt(i) == 'N') y++;
            if (s.charAt(i) == 'E') x++;
            if (s.charAt(i) == 'W') x--;
            if (s.charAt(i) == 'S') y--;
        }
        
        System.out.println(Math.sqrt(Math.pow(x,2)+Math.pow(y,2)));
    }
}
0