結果

問題 No.113 宝探し
ユーザー takeya_okinotakeya_okino
提出日時 2017-06-25 12:07:03
言語 Java21
(openjdk 21)
結果
AC  
実行時間 123 ms / 5,000 ms
コード長 442 bytes
コンパイル時間 2,237 ms
コンパイル使用メモリ 72,508 KB
実行使用メモリ 56,436 KB
最終ジャッジ日時 2023-08-10 14:55:50
合計ジャッジ時間 6,473 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 115 ms
55,552 KB
testcase_01 AC 115 ms
56,216 KB
testcase_02 AC 115 ms
55,768 KB
testcase_03 AC 116 ms
55,600 KB
testcase_04 AC 116 ms
55,976 KB
testcase_05 AC 115 ms
55,248 KB
testcase_06 AC 119 ms
55,772 KB
testcase_07 AC 114 ms
55,860 KB
testcase_08 AC 114 ms
55,828 KB
testcase_09 AC 116 ms
55,788 KB
testcase_10 AC 115 ms
55,900 KB
testcase_11 AC 114 ms
55,872 KB
testcase_12 AC 116 ms
55,676 KB
testcase_13 AC 115 ms
55,732 KB
testcase_14 AC 115 ms
55,592 KB
testcase_15 AC 115 ms
56,064 KB
testcase_16 AC 115 ms
56,436 KB
testcase_17 AC 115 ms
55,596 KB
testcase_18 AC 116 ms
55,424 KB
testcase_19 AC 115 ms
55,952 KB
testcase_20 AC 116 ms
55,964 KB
testcase_21 AC 116 ms
54,460 KB
testcase_22 AC 119 ms
55,696 KB
testcase_23 AC 123 ms
55,672 KB
testcase_24 AC 120 ms
55,688 KB
testcase_25 AC 118 ms
56,076 KB
testcase_26 AC 115 ms
55,856 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