結果

問題 No.113 宝探し
ユーザー atkrymatkrym
提出日時 2016-10-25 20:59:31
言語 Java21
(openjdk 21)
結果
WA  
実行時間 -
コード長 531 bytes
コンパイル時間 1,900 ms
コンパイル使用メモリ 75,824 KB
実行使用メモリ 55,996 KB
最終ジャッジ日時 2024-05-03 06:02:50
合計ジャッジ時間 6,007 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 117 ms
41,204 KB
testcase_02 AC 124 ms
40,864 KB
testcase_03 AC 110 ms
41,164 KB
testcase_04 WA -
testcase_05 AC 99 ms
41,228 KB
testcase_06 AC 113 ms
41,192 KB
testcase_07 AC 113 ms
41,196 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 AC 122 ms
40,968 KB
testcase_14 WA -
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 114 ms
41,488 KB
testcase_18 AC 100 ms
40,960 KB
testcase_19 AC 99 ms
41,440 KB
testcase_20 AC 113 ms
41,272 KB
testcase_21 AC 114 ms
41,124 KB
testcase_22 AC 104 ms
41,328 KB
testcase_23 AC 111 ms
40,960 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 AC 112 ms
41,220 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') y--;
            if (s.charAt(i) == 'S') x--;
        }
        
        System.out.println(Math.sqrt(Math.pow(x,2)+Math.pow(y,2)));
    }
}
0