結果

問題 No.113 宝探し
ユーザー mits58
提出日時 2016-07-02 00:54:15
言語 Java
(openjdk 23)
結果
AC  
実行時間 119 ms / 5,000 ms
コード長 403 bytes
コンパイル時間 2,020 ms
コンパイル使用メモリ 74,088 KB
実行使用メモリ 41,228 KB
最終ジャッジ日時 2024-11-16 21:20:17
合計ジャッジ時間 5,849 ms
ジャッジサーバーID
(参考情報)
judge5 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

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