結果

問題 No.113 宝探し
ユーザー ぴろずぴろず
提出日時 2014-12-28 23:24:48
言語 Java
(openjdk 23)
結果
AC  
実行時間 126 ms / 5,000 ms
コード長 443 bytes
コンパイル時間 2,270 ms
コンパイル使用メモリ 74,664 KB
実行使用メモリ 41,444 KB
最終ジャッジ日時 2024-11-16 20:33:45
合計ジャッジ時間 6,300 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

package no113;

import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = 0, y = 0;
		char[] s = sc.next().toCharArray();
		for(int i=0;i<s.length;i++) {
			switch (s[i]) {
			case 'N':
				y++;
				break;
			case 'S':
				y--;
				break;
			case 'E':
				x++;
				break;
			case 'W':
				x--;
				break;
			}
		}
		System.out.println(Math.sqrt(x*x+y*y));
	}

}
0