結果

問題 No.113 宝探し
ユーザー htensai
提出日時 2019-12-05 15:04:17
言語 Java
(openjdk 23)
結果
AC  
実行時間 122 ms / 5,000 ms
コード長 474 bytes
コンパイル時間 1,984 ms
コンパイル使用メモリ 73,992 KB
実行使用メモリ 41,452 KB
最終ジャッジ日時 2024-11-16 22:20:53
合計ジャッジ時間 6,021 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		char[] arr = sc.next().toCharArray();
	    int x = 0;
	    int y = 0;
	    for (char c : arr) {
	        if (c == 'N') {
	            y++;
	        } else if (c == 'S') {
	            y--;
	        } else if (c == 'E') {
	            x++;
	        } else {
	            x--;
	        }
	    }
		System.out.println(Math.sqrt(x * x + y * y));
   }
}

0