結果

問題 No.113 宝探し
ユーザー kohaku_kohakukohaku_kohaku
提出日時 2016-11-12 08:17:55
言語 Java21
(openjdk 21)
結果
AC  
実行時間 134 ms / 5,000 ms
コード長 678 bytes
コンパイル時間 2,097 ms
コンパイル使用メモリ 74,056 KB
実行使用メモリ 54,276 KB
最終ジャッジ日時 2024-04-28 07:52:13
合計ジャッジ時間 6,688 ms
ジャッジサーバーID
(参考情報)
judge2 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 131 ms
53,608 KB
testcase_01 AC 127 ms
53,616 KB
testcase_02 AC 129 ms
53,824 KB
testcase_03 AC 129 ms
53,772 KB
testcase_04 AC 130 ms
53,852 KB
testcase_05 AC 130 ms
53,620 KB
testcase_06 AC 128 ms
53,936 KB
testcase_07 AC 132 ms
53,872 KB
testcase_08 AC 129 ms
53,992 KB
testcase_09 AC 133 ms
53,708 KB
testcase_10 AC 131 ms
53,760 KB
testcase_11 AC 132 ms
53,844 KB
testcase_12 AC 130 ms
53,764 KB
testcase_13 AC 132 ms
53,996 KB
testcase_14 AC 130 ms
54,276 KB
testcase_15 AC 129 ms
53,484 KB
testcase_16 AC 132 ms
54,040 KB
testcase_17 AC 130 ms
54,116 KB
testcase_18 AC 130 ms
53,880 KB
testcase_19 AC 132 ms
53,836 KB
testcase_20 AC 132 ms
53,492 KB
testcase_21 AC 131 ms
53,848 KB
testcase_22 AC 134 ms
54,240 KB
testcase_23 AC 128 ms
54,016 KB
testcase_24 AC 131 ms
53,588 KB
testcase_25 AC 131 ms
53,740 KB
testcase_26 AC 129 ms
53,628 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String S = sc.nextLine();
        String [] arr = S.split("");
        int mx = 0;
        int my = 0;
        for(int i=0; i<arr.length; i++){
            if( arr[i].equals("N") ){
                my = my + 1;
            }else if( arr[i].equals("S") ){
                my = my - 1;
            }else if( arr[i].equals("E") ){
                mx = mx + 1;
            }else if( arr[i].equals("W") ){
                mx = mx - 1;
            }
        }
        double dis = Math.sqrt(mx*mx+my*my);
        System.out.println(dis);
    }
}
0