結果

問題 No.113 宝探し
ユーザー mits58mits58
提出日時 2016-07-02 00:54:15
言語 Java21
(openjdk 21)
結果
AC  
実行時間 142 ms / 5,000 ms
コード長 403 bytes
コンパイル時間 2,691 ms
コンパイル使用メモリ 74,308 KB
実行使用メモリ 54,380 KB
最終ジャッジ日時 2024-04-28 07:46:04
合計ジャッジ時間 6,892 ms
ジャッジサーバーID
(参考情報)
judge1 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 129 ms
53,788 KB
testcase_01 AC 133 ms
54,156 KB
testcase_02 AC 129 ms
53,892 KB
testcase_03 AC 128 ms
53,956 KB
testcase_04 AC 129 ms
53,912 KB
testcase_05 AC 128 ms
54,380 KB
testcase_06 AC 130 ms
53,948 KB
testcase_07 AC 131 ms
54,008 KB
testcase_08 AC 130 ms
53,748 KB
testcase_09 AC 131 ms
54,328 KB
testcase_10 AC 128 ms
54,084 KB
testcase_11 AC 127 ms
54,072 KB
testcase_12 AC 127 ms
54,196 KB
testcase_13 AC 128 ms
53,896 KB
testcase_14 AC 124 ms
54,216 KB
testcase_15 AC 132 ms
53,904 KB
testcase_16 AC 130 ms
53,956 KB
testcase_17 AC 129 ms
53,884 KB
testcase_18 AC 126 ms
54,048 KB
testcase_19 AC 127 ms
54,196 KB
testcase_20 AC 125 ms
53,924 KB
testcase_21 AC 132 ms
54,040 KB
testcase_22 AC 142 ms
54,304 KB
testcase_23 AC 138 ms
54,248 KB
testcase_24 AC 130 ms
54,004 KB
testcase_25 AC 131 ms
53,944 KB
testcase_26 AC 128 ms
53,688 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		while(sc.hasNext()){
			double x=0,y=0;
			String str=sc.next();
			for(int i=0;i<str.length();i++){
				if(str.charAt(i)=='N') y++;
				else if(str.charAt(i)=='E') x++;
				else if(str.charAt(i)=='W') x--;
				else y--;
			}
			System.out.println(Math.sqrt(x*x+y*y));
		}
	}
}
0