結果

問題 No.113 宝探し
ユーザー Taka
提出日時 2016-03-31 03:31:05
言語 Java
(openjdk 23)
結果
RE  
実行時間 -
コード長 639 bytes
コンパイル時間 3,615 ms
コンパイル使用メモリ 74,964 KB
実行使用メモリ 41,796 KB
最終ジャッジ日時 2024-10-02 08:20:58
合計ジャッジ時間 8,005 ms
ジャッジサーバーID
(参考情報)
judge2 / judge3
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample RE * 4
other RE * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class HelloWorld{
		public static void main(String[] args) {
			// 標準入力から読み込む際に、Scannerオブジェクトを使う。
	        Scanner sc = new Scanner(System.in);
			
			int i=0;
			char word;
			double x=0, y=0, kyori=0;
			
			int target = sc.nextInt(); //入力する
			
			String str=String.valueOf(target);
			
			while(i<str.length())
			{
				word=str.charAt(i);
				
				if(word=='N')	y = y+1;
				else if(word=='S')	y = y-1;
				else if(word=='E')	x = x+1;
				else if(word=='W')	x = x-1;
				i++;
			}
			kyori=Math.sqrt(x*x+y*y);
			System.out.println(kyori);
		}
}
0