結果

問題 No.113 宝探し
ユーザー NeigNeig
提出日時 2016-03-31 03:52:16
言語 Java21
(openjdk 21)
結果
AC  
実行時間 117 ms / 5,000 ms
コード長 600 bytes
コンパイル時間 3,467 ms
コンパイル使用メモリ 76,928 KB
実行使用メモリ 41,228 KB
最終ジャッジ日時 2024-04-28 07:39:10
合計ジャッジ時間 6,646 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 117 ms
40,876 KB
testcase_01 AC 108 ms
39,996 KB
testcase_02 AC 117 ms
40,716 KB
testcase_03 AC 110 ms
40,992 KB
testcase_04 AC 111 ms
40,112 KB
testcase_05 AC 97 ms
40,160 KB
testcase_06 AC 102 ms
40,176 KB
testcase_07 AC 110 ms
41,228 KB
testcase_08 AC 100 ms
40,248 KB
testcase_09 AC 103 ms
40,652 KB
testcase_10 AC 100 ms
40,996 KB
testcase_11 AC 102 ms
40,964 KB
testcase_12 AC 93 ms
40,320 KB
testcase_13 AC 107 ms
40,680 KB
testcase_14 AC 102 ms
40,928 KB
testcase_15 AC 106 ms
40,112 KB
testcase_16 AC 112 ms
40,936 KB
testcase_17 AC 115 ms
40,912 KB
testcase_18 AC 91 ms
39,924 KB
testcase_19 AC 108 ms
40,680 KB
testcase_20 AC 97 ms
39,824 KB
testcase_21 AC 107 ms
41,016 KB
testcase_22 AC 93 ms
40,248 KB
testcase_23 AC 108 ms
40,588 KB
testcase_24 AC 95 ms
40,168 KB
testcase_25 AC 108 ms
40,860 KB
testcase_26 AC 112 ms
41,044 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;


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

        int x = 0,y = 0;
        double d;

        String s = sc.next();

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

          char  a = s.charAt(i);

          if (a == 'N') {
            x = x + 1;
          }else if (a == 'S') {
            x = x - 1;
          }else if (a == 'W') {
            y = y + 1;
          }else if (a =='E')
            y = y - 1;
        }
      d = Math.sqrt(x*x + y*y);

        System.out.println(d );
    }
}
0