結果

問題 No.113 宝探し
ユーザー FVRChanFVRChan
提出日時 2017-09-24 15:36:30
言語 Java
(openjdk 23)
結果
AC  
実行時間 118 ms / 5,000 ms
コード長 390 bytes
コンパイル時間 2,204 ms
コンパイル使用メモリ 74,868 KB
実行使用メモリ 41,168 KB
最終ジャッジ日時 2024-11-16 21:37:31
合計ジャッジ時間 5,530 ms
ジャッジサーバーID
(参考情報)
judge1 / judge5
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 4
other AC * 23
権限があれば一括ダウンロードができます

ソースコード

diff #

import java.util.Scanner;
public class Main{
	public static void main(String args[])throws Exception{
		Scanner sc=new Scanner(System.in);
		char c[]=sc.nextLine().toCharArray();
		int x=0,y=0;

		for(int i=0;i<c.length;i++){
			switch(c[i]){
			case'N':y--;break;
			case'E':x++;break;
			case'S':y++;break;
			case'W':x--;break;
			}
		}
		System.out.println(Math.sqrt((x*x)+(y*y)));
	}
}
0