結果

問題 No.113 宝探し
ユーザー k_kadorak_kadora
提出日時 2015-05-25 23:55:38
言語 Java21
(openjdk 21)
結果
AC  
実行時間 117 ms / 5,000 ms
コード長 441 bytes
コンパイル時間 2,991 ms
コンパイル使用メモリ 75,000 KB
実行使用メモリ 41,364 KB
最終ジャッジ日時 2024-04-28 07:25:35
合計ジャッジ時間 6,675 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 105 ms
40,172 KB
testcase_01 AC 111 ms
40,804 KB
testcase_02 AC 108 ms
41,272 KB
testcase_03 AC 100 ms
40,360 KB
testcase_04 AC 107 ms
40,816 KB
testcase_05 AC 113 ms
40,772 KB
testcase_06 AC 102 ms
40,076 KB
testcase_07 AC 110 ms
40,928 KB
testcase_08 AC 110 ms
41,128 KB
testcase_09 AC 94 ms
39,832 KB
testcase_10 AC 98 ms
39,972 KB
testcase_11 AC 105 ms
40,924 KB
testcase_12 AC 102 ms
40,336 KB
testcase_13 AC 100 ms
40,248 KB
testcase_14 AC 98 ms
40,132 KB
testcase_15 AC 104 ms
41,048 KB
testcase_16 AC 101 ms
41,240 KB
testcase_17 AC 106 ms
40,836 KB
testcase_18 AC 98 ms
39,736 KB
testcase_19 AC 100 ms
40,112 KB
testcase_20 AC 108 ms
41,216 KB
testcase_21 AC 114 ms
40,608 KB
testcase_22 AC 117 ms
41,252 KB
testcase_23 AC 113 ms
41,352 KB
testcase_24 AC 109 ms
41,072 KB
testcase_25 AC 102 ms
39,856 KB
testcase_26 AC 111 ms
41,364 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;
public class Treasure{
	public static void main(String[] arg){
		Scanner sc = new Scanner(System.in);
		int x=0,y=0;
		double res;
		String in;
		in = sc.next();
		int l = in.length();
		for(int i = 0;i<l;i++){
			if(in.charAt(i) == 'N'){
				y++;
			}else if(in.charAt(i) == 'E'){
				x++;
			}else if(in.charAt(i) == 'S'){
				y--;
			}else{
				x--;
			}
		}
		res = Math.sqrt(x*x+y*y);
		System.out.println(res);
	}
}
0