結果

問題 No.113 宝探し
ユーザー yamax3232yamax3232
提出日時 2018-03-15 08:18:51
言語 Java21
(openjdk 21)
結果
AC  
実行時間 125 ms / 5,000 ms
コード長 460 bytes
コンパイル時間 2,569 ms
コンパイル使用メモリ 80,668 KB
実行使用メモリ 41,268 KB
最終ジャッジ日時 2024-04-28 08:10:10
合計ジャッジ時間 5,291 ms
ジャッジサーバーID
(参考情報)
judge2 / judge4
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 93 ms
40,152 KB
testcase_01 AC 106 ms
41,084 KB
testcase_02 AC 108 ms
41,180 KB
testcase_03 AC 105 ms
41,020 KB
testcase_04 AC 106 ms
41,072 KB
testcase_05 AC 105 ms
41,096 KB
testcase_06 AC 91 ms
39,500 KB
testcase_07 AC 104 ms
39,948 KB
testcase_08 AC 103 ms
41,268 KB
testcase_09 AC 101 ms
40,972 KB
testcase_10 AC 111 ms
41,056 KB
testcase_11 AC 106 ms
41,004 KB
testcase_12 AC 101 ms
39,992 KB
testcase_13 AC 101 ms
40,992 KB
testcase_14 AC 87 ms
39,920 KB
testcase_15 AC 105 ms
40,928 KB
testcase_16 AC 101 ms
40,928 KB
testcase_17 AC 103 ms
41,196 KB
testcase_18 AC 95 ms
39,992 KB
testcase_19 AC 107 ms
41,020 KB
testcase_20 AC 103 ms
40,724 KB
testcase_21 AC 102 ms
41,136 KB
testcase_22 AC 98 ms
40,216 KB
testcase_23 AC 107 ms
41,040 KB
testcase_24 AC 102 ms
40,072 KB
testcase_25 AC 125 ms
40,852 KB
testcase_26 AC 94 ms
40,320 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		int x=0;
		int y=0;
		Scanner kb=new Scanner(System.in);
		String s=kb.nextLine();
		for(int i=0;i<s.length();i++){
			if(s.charAt(i)=='N'){
				y++;
			}if(s.charAt(i)=='E'){
				x++;
			}if(s.charAt(i)=='S'){
				y--;
			}if(s.charAt(i)=='W'){
				x--;
			}
		}
		System.out.println(Math.sqrt(x*x+y*y));

	}
}
0