結果

問題 No.113 宝探し
ユーザー SuunnSuunn
提出日時 2018-11-20 07:22:41
言語 Java21
(openjdk 21)
結果
AC  
実行時間 114 ms / 5,000 ms
コード長 499 bytes
コンパイル時間 1,810 ms
コンパイル使用メモリ 80,588 KB
実行使用メモリ 41,216 KB
最終ジャッジ日時 2024-04-28 08:17:34
合計ジャッジ時間 5,428 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 106 ms
40,876 KB
testcase_01 AC 100 ms
40,788 KB
testcase_02 AC 95 ms
39,852 KB
testcase_03 AC 93 ms
39,748 KB
testcase_04 AC 103 ms
40,828 KB
testcase_05 AC 107 ms
40,860 KB
testcase_06 AC 98 ms
39,856 KB
testcase_07 AC 96 ms
40,176 KB
testcase_08 AC 92 ms
39,480 KB
testcase_09 AC 98 ms
39,868 KB
testcase_10 AC 97 ms
40,000 KB
testcase_11 AC 96 ms
40,320 KB
testcase_12 AC 106 ms
41,020 KB
testcase_13 AC 94 ms
39,848 KB
testcase_14 AC 108 ms
40,940 KB
testcase_15 AC 98 ms
40,032 KB
testcase_16 AC 104 ms
41,216 KB
testcase_17 AC 104 ms
40,752 KB
testcase_18 AC 93 ms
40,104 KB
testcase_19 AC 114 ms
40,896 KB
testcase_20 AC 106 ms
40,844 KB
testcase_21 AC 93 ms
39,592 KB
testcase_22 AC 104 ms
41,128 KB
testcase_23 AC 105 ms
40,996 KB
testcase_24 AC 98 ms
40,776 KB
testcase_25 AC 106 ms
40,884 KB
testcase_26 AC 104 ms
40,840 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
	

public class Main{
	
	
	public static void main(String args[])throws Exception{
		Scanner sc = new Scanner(System.in);
		String S = sc.next();
		int x = 0;
		int y = 0;
		int L = S.length();
		for(int i=0;i<L;i++){
			char c = S.charAt(i);
			
			switch(c){
			
			case 'N':
				y++;
				break;
			case 'E':
				x++;
				break;
			case 'W':
				x--;
				break;
			case 'S':
				y--;
				break;
			}
		}
		
		System.out.println(Math.pow((double)(x*x+y*y), 0.5));
	}
	

}
0