結果

問題 No.113 宝探し
ユーザー jimanojimano
提出日時 2018-01-18 19:46:52
言語 Java21
(openjdk 21)
結果
AC  
実行時間 50 ms / 5,000 ms
コード長 929 bytes
コンパイル時間 3,010 ms
コンパイル使用メモリ 77,012 KB
実行使用メモリ 37,672 KB
最終ジャッジ日時 2024-04-28 08:06:50
合計ジャッジ時間 5,301 ms
ジャッジサーバーID
(参考情報)
judge3 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 48 ms
37,672 KB
testcase_01 AC 46 ms
37,404 KB
testcase_02 AC 46 ms
37,272 KB
testcase_03 AC 45 ms
37,188 KB
testcase_04 AC 48 ms
37,624 KB
testcase_05 AC 48 ms
37,344 KB
testcase_06 AC 47 ms
37,624 KB
testcase_07 AC 47 ms
37,556 KB
testcase_08 AC 46 ms
37,148 KB
testcase_09 AC 47 ms
37,432 KB
testcase_10 AC 46 ms
37,432 KB
testcase_11 AC 47 ms
37,584 KB
testcase_12 AC 48 ms
37,536 KB
testcase_13 AC 47 ms
37,480 KB
testcase_14 AC 46 ms
37,628 KB
testcase_15 AC 47 ms
37,432 KB
testcase_16 AC 45 ms
37,180 KB
testcase_17 AC 48 ms
37,560 KB
testcase_18 AC 47 ms
37,588 KB
testcase_19 AC 46 ms
37,652 KB
testcase_20 AC 47 ms
37,172 KB
testcase_21 AC 46 ms
37,408 KB
testcase_22 AC 49 ms
37,580 KB
testcase_23 AC 47 ms
37,568 KB
testcase_24 AC 47 ms
37,428 KB
testcase_25 AC 50 ms
37,404 KB
testcase_26 AC 47 ms
37,268 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package me.yukicoder.lv1;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.RoundingMode;

public class No0113 {
	public static void main(String[] args) {
		try (BufferedReader br = new BufferedReader(new InputStreamReader(System.in))) {
			char[] array = br.readLine().toCharArray();
			double[] point = new double[2];

			for (char c : array) {
				if (c == 'N') {
					point[0] += 1.0;
				} else if (c == 'E') {
					point[1] += 1.0;
				} else if (c == 'W') {
					point[1] -= 1.0;
				} else if (c == 'S') {
					point[0] -= 1.0;
				}
			}
			double d = Math.pow(Math.abs(point[0]), 2) + Math.pow(Math.abs(point[1]), 2);
			double dist = Math.sqrt(d);
			BigDecimal ans = new BigDecimal(dist);
			ans = ans.setScale(5, RoundingMode.HALF_DOWN);
			System.out.println(ans);
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
}
0