結果

問題 No.113 宝探し
ユーザー rf141
提出日時 2015-08-10 02:56:59
言語 Java
(openjdk 23)
結果
AC  
実行時間 112 ms / 5,000 ms
コード長 509 bytes
コンパイル時間 3,853 ms
コンパイル使用メモリ 75,376 KB
実行使用メモリ 41,420 KB
最終ジャッジ日時 2024-11-16 20:58:47
合計ジャッジ時間 6,447 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

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){
		double x=0,y=0;
		for(int i = 0; i < point.length(); i++){
			String now = point.substring(i,i+1);
			if(now.equals("N")){
				y++;
			}else if(now.equals("E")){
				x++;
			}else if(now.equals("W")){
				x--;
			}else{
				y--;
			}
		}
		System.out.println(Math.sqrt(x*x+y*y));
	}
}
0