結果

問題 No.113 宝探し
ユーザー rf141rf141
提出日時 2015-08-10 02:53:55
言語 Java21
(openjdk 21)
結果
AC  
実行時間 115 ms / 5,000 ms
コード長 783 bytes
コンパイル時間 3,084 ms
コンパイル使用メモリ 77,676 KB
実行使用メモリ 41,584 KB
最終ジャッジ日時 2024-04-28 07:27:07
合計ジャッジ時間 6,690 ms
ジャッジサーバーID
(参考情報)
judge4 / judge3
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 101 ms
39,932 KB
testcase_01 AC 99 ms
40,956 KB
testcase_02 AC 99 ms
40,224 KB
testcase_03 AC 115 ms
41,340 KB
testcase_04 AC 106 ms
41,584 KB
testcase_05 AC 99 ms
41,216 KB
testcase_06 AC 112 ms
41,108 KB
testcase_07 AC 107 ms
41,056 KB
testcase_08 AC 99 ms
41,188 KB
testcase_09 AC 109 ms
41,584 KB
testcase_10 AC 104 ms
40,052 KB
testcase_11 AC 98 ms
40,176 KB
testcase_12 AC 112 ms
41,288 KB
testcase_13 AC 111 ms
41,156 KB
testcase_14 AC 110 ms
40,996 KB
testcase_15 AC 101 ms
41,008 KB
testcase_16 AC 99 ms
41,152 KB
testcase_17 AC 113 ms
40,952 KB
testcase_18 AC 105 ms
41,236 KB
testcase_19 AC 112 ms
41,304 KB
testcase_20 AC 114 ms
40,864 KB
testcase_21 AC 111 ms
41,508 KB
testcase_22 AC 112 ms
40,996 KB
testcase_23 AC 97 ms
41,008 KB
testcase_24 AC 99 ms
40,884 KB
testcase_25 AC 100 ms
40,952 KB
testcase_26 AC 111 ms
41,156 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
public class searchBox{
	public static void main(String... args){
		Scanner scan = new Scanner(System.in);
		String point = scan.next();
		DoSearch(point);
	}
	public static void DoSearch(String point){
		int[] count_point = {0,0,0,0};//N,E,W,S
		for(int i = 0; i < point.length(); i++){
			String now = point.substring(i,i+1);
			if(now.equals("N")){
				count_point[0]+=1;
			}else if(now.equals("E")){
				count_point[1]+=1;
			}else if(now.equals("W")){
				count_point[2]+=1;
			}else{
				count_point[3]+=1;
			}
		}
		int[] right = {count_point[1],count_point[0]};//x,y
		int[] left = {count_point[2]*(-1),count_point[3]*(-1)};
		double x = Math.pow(right[0]+left[0],2);
		double y = Math.pow(right[1]+left[1],2);
		System.out.println(Math.sqrt(x+y));
	}
}
0