結果

問題 No.113 宝探し
ユーザー nCk_cvnCk_cv
提出日時 2016-01-21 02:35:43
言語 Java21
(openjdk 21)
結果
AC  
実行時間 111 ms / 5,000 ms
コード長 467 bytes
コンパイル時間 2,062 ms
コンパイル使用メモリ 74,148 KB
実行使用メモリ 41,276 KB
最終ジャッジ日時 2024-04-28 07:35:11
合計ジャッジ時間 5,564 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 97 ms
40,168 KB
testcase_01 AC 98 ms
40,020 KB
testcase_02 AC 111 ms
41,276 KB
testcase_03 AC 93 ms
39,880 KB
testcase_04 AC 101 ms
40,560 KB
testcase_05 AC 103 ms
40,712 KB
testcase_06 AC 103 ms
40,876 KB
testcase_07 AC 103 ms
41,228 KB
testcase_08 AC 105 ms
40,976 KB
testcase_09 AC 96 ms
39,980 KB
testcase_10 AC 102 ms
40,024 KB
testcase_11 AC 104 ms
40,048 KB
testcase_12 AC 100 ms
40,160 KB
testcase_13 AC 110 ms
40,872 KB
testcase_14 AC 95 ms
40,212 KB
testcase_15 AC 102 ms
40,888 KB
testcase_16 AC 106 ms
41,008 KB
testcase_17 AC 105 ms
40,908 KB
testcase_18 AC 105 ms
40,896 KB
testcase_19 AC 104 ms
40,776 KB
testcase_20 AC 108 ms
40,960 KB
testcase_21 AC 104 ms
41,032 KB
testcase_22 AC 103 ms
41,112 KB
testcase_23 AC 103 ms
40,900 KB
testcase_24 AC 109 ms
39,592 KB
testcase_25 AC 108 ms
40,876 KB
testcase_26 AC 105 ms
40,212 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
import java.math.*;
import java.io.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] in = sc.next().toCharArray();
		int x = 0;
		int y = 0;
		for(int i = 0; i < in.length; i++) {
			if(in[i] == 'N') y++;
			if(in[i] == 'S') y--;
			if(in[i] == 'W') x--;
			if(in[i] == 'E') x++;
		}
		double ans = Math.sqrt(Math.pow(x, 2) + Math.pow(y, 2));
		System.out.printf("%.20f\n",ans);
	}
}
0