結果

問題 No.113 宝探し
ユーザー TakaTaka
提出日時 2016-03-31 03:33:14
言語 Java21
(openjdk 21)
結果
AC  
実行時間 118 ms / 5,000 ms
コード長 594 bytes
コンパイル時間 2,944 ms
コンパイル使用メモリ 74,264 KB
実行使用メモリ 41,304 KB
最終ジャッジ日時 2024-04-28 07:39:01
合計ジャッジ時間 6,794 ms
ジャッジサーバーID
(参考情報)
judge4 / judge2
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 99 ms
40,332 KB
testcase_01 AC 109 ms
41,164 KB
testcase_02 AC 114 ms
40,796 KB
testcase_03 AC 112 ms
41,212 KB
testcase_04 AC 110 ms
41,256 KB
testcase_05 AC 104 ms
40,312 KB
testcase_06 AC 109 ms
41,176 KB
testcase_07 AC 95 ms
40,320 KB
testcase_08 AC 113 ms
41,152 KB
testcase_09 AC 109 ms
41,084 KB
testcase_10 AC 118 ms
41,236 KB
testcase_11 AC 104 ms
40,076 KB
testcase_12 AC 104 ms
40,216 KB
testcase_13 AC 113 ms
40,224 KB
testcase_14 AC 109 ms
39,976 KB
testcase_15 AC 109 ms
41,304 KB
testcase_16 AC 108 ms
40,716 KB
testcase_17 AC 108 ms
41,040 KB
testcase_18 AC 107 ms
40,968 KB
testcase_19 AC 104 ms
39,836 KB
testcase_20 AC 99 ms
39,856 KB
testcase_21 AC 106 ms
40,896 KB
testcase_22 AC 96 ms
40,320 KB
testcase_23 AC 112 ms
41,056 KB
testcase_24 AC 109 ms
40,136 KB
testcase_25 AC 95 ms
39,996 KB
testcase_26 AC 118 ms
41,108 KB
権限があれば一括ダウンロードができます

ソースコード

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;
			
			String str = sc.next(); //入力する
			
			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