結果

問題 No.113 宝探し
ユーザー GrenacheGrenache
提出日時 2015-09-23 20:13:42
言語 Java21
(openjdk 21)
結果
AC  
実行時間 120 ms / 5,000 ms
コード長 610 bytes
コンパイル時間 3,039 ms
コンパイル使用メモリ 74,404 KB
実行使用メモリ 41,528 KB
最終ジャッジ日時 2024-04-28 07:28:28
合計ジャッジ時間 6,987 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 106 ms
41,184 KB
testcase_01 AC 114 ms
41,184 KB
testcase_02 AC 110 ms
41,488 KB
testcase_03 AC 111 ms
41,184 KB
testcase_04 AC 100 ms
41,116 KB
testcase_05 AC 110 ms
41,528 KB
testcase_06 AC 112 ms
41,060 KB
testcase_07 AC 114 ms
41,356 KB
testcase_08 AC 105 ms
40,196 KB
testcase_09 AC 107 ms
40,012 KB
testcase_10 AC 107 ms
40,940 KB
testcase_11 AC 112 ms
41,460 KB
testcase_12 AC 114 ms
41,344 KB
testcase_13 AC 120 ms
41,268 KB
testcase_14 AC 112 ms
41,172 KB
testcase_15 AC 111 ms
41,468 KB
testcase_16 AC 112 ms
41,100 KB
testcase_17 AC 113 ms
40,812 KB
testcase_18 AC 109 ms
41,244 KB
testcase_19 AC 104 ms
40,032 KB
testcase_20 AC 98 ms
41,276 KB
testcase_21 AC 108 ms
40,428 KB
testcase_22 AC 107 ms
41,320 KB
testcase_23 AC 107 ms
41,176 KB
testcase_24 AC 99 ms
41,308 KB
testcase_25 AC 101 ms
41,340 KB
testcase_26 AC 100 ms
41,004 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;


public class Main_yukicoder113 {

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

        char[] s = sc.next().toCharArray();
        int x = 0;
        int y = 0;
        for (char e : s) {
        	switch (e) {
        	case 'N':
        		y++;
        		break;
        	case 'E':
        		x++;
        		break;
        	case 'W':
        		x--;
        		break;
        	case 'S':
        		y--;
        		break;
        	}
        }

        System.out.printf("%.3f\n", Math.sqrt(x * x + y * y));
        
        sc.close();
    }
}
0