結果

問題 No.113 宝探し
ユーザー takeya_okinotakeya_okino
提出日時 2017-06-25 12:07:03
言語 Java21
(openjdk 21)
結果
AC  
実行時間 127 ms / 5,000 ms
コード長 442 bytes
コンパイル時間 2,048 ms
コンパイル使用メモリ 74,748 KB
実行使用メモリ 41,400 KB
最終ジャッジ日時 2024-04-28 07:56:50
合計ジャッジ時間 5,606 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 111 ms
40,304 KB
testcase_01 AC 127 ms
41,172 KB
testcase_02 AC 100 ms
40,796 KB
testcase_03 AC 100 ms
41,100 KB
testcase_04 AC 102 ms
40,936 KB
testcase_05 AC 93 ms
39,836 KB
testcase_06 AC 103 ms
40,804 KB
testcase_07 AC 107 ms
41,400 KB
testcase_08 AC 96 ms
39,932 KB
testcase_09 AC 99 ms
40,076 KB
testcase_10 AC 102 ms
40,948 KB
testcase_11 AC 107 ms
40,216 KB
testcase_12 AC 115 ms
41,284 KB
testcase_13 AC 94 ms
40,040 KB
testcase_14 AC 105 ms
41,096 KB
testcase_15 AC 113 ms
40,992 KB
testcase_16 AC 92 ms
40,008 KB
testcase_17 AC 86 ms
39,772 KB
testcase_18 AC 91 ms
39,664 KB
testcase_19 AC 91 ms
39,976 KB
testcase_20 AC 102 ms
41,028 KB
testcase_21 AC 98 ms
41,160 KB
testcase_22 AC 107 ms
40,828 KB
testcase_23 AC 96 ms
39,996 KB
testcase_24 AC 91 ms
40,216 KB
testcase_25 AC 99 ms
40,024 KB
testcase_26 AC 105 ms
41,060 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String s = sc.next();
    int x = 0;
    int y = 0;
    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--;
    }
    double ans = Math.sqrt(x * x + y * y);
    System.out.println(ans);
  }
}
0