結果

問題 No.113 宝探し
ユーザー 37zigen37zigen
提出日時 2016-03-31 18:53:10
言語 Java21
(openjdk 21)
結果
AC  
実行時間 130 ms / 5,000 ms
コード長 444 bytes
コンパイル時間 2,131 ms
コンパイル使用メモリ 78,956 KB
実行使用メモリ 41,680 KB
最終ジャッジ日時 2024-04-28 07:39:45
合計ジャッジ時間 6,539 ms
ジャッジサーバーID
(参考情報)
judge5 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 126 ms
40,928 KB
testcase_01 AC 125 ms
41,052 KB
testcase_02 AC 126 ms
41,412 KB
testcase_03 AC 127 ms
41,060 KB
testcase_04 AC 127 ms
41,052 KB
testcase_05 AC 130 ms
41,064 KB
testcase_06 AC 129 ms
41,196 KB
testcase_07 AC 129 ms
40,980 KB
testcase_08 AC 124 ms
41,680 KB
testcase_09 AC 125 ms
40,948 KB
testcase_10 AC 122 ms
41,124 KB
testcase_11 AC 121 ms
41,196 KB
testcase_12 AC 129 ms
41,456 KB
testcase_13 AC 127 ms
41,284 KB
testcase_14 AC 130 ms
41,108 KB
testcase_15 AC 126 ms
41,228 KB
testcase_16 AC 113 ms
40,076 KB
testcase_17 AC 127 ms
41,208 KB
testcase_18 AC 129 ms
41,536 KB
testcase_19 AC 125 ms
41,120 KB
testcase_20 AC 127 ms
40,720 KB
testcase_21 AC 123 ms
40,896 KB
testcase_22 AC 111 ms
40,104 KB
testcase_23 AC 109 ms
40,076 KB
testcase_24 AC 113 ms
40,140 KB
testcase_25 AC 124 ms
41,196 KB
testcase_26 AC 114 ms
39,640 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

package yukicoder113;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		double x=0;
		double y=0;
		String str=sc.next();
		char[] c=str.toCharArray();
		for(int i=0;i<c.length;i++){
			if(c[i]=='N'){
				y++;
			}else if(c[i]=='S'){
				y--;
			}else if(c[i]=='W'){
				x--;			
			}else if(c[i]=='E'){
				x++;
			}
		}
		System.out.println(Math.sqrt(x*x+y*y));
	}
}
0