結果
問題 |
No.113 宝探し
|
ユーザー |
![]() |
提出日時 | 2017-04-29 06:59:39 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 47 ms / 5,000 ms |
コード長 | 830 bytes |
コンパイル時間 | 1,916 ms |
コンパイル使用メモリ | 72,976 KB |
実行使用メモリ | 37,020 KB |
最終ジャッジ日時 | 2024-11-16 21:32:29 |
合計ジャッジ時間 | 4,004 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge5 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 23 |
ソースコード
import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; public class Main { public static void main(String[] args) throws IOException { BufferedReader reader = new BufferedReader(new InputStreamReader(System.in)); String S = reader.readLine(); int x = 0; int y = 0; for (int i = 0; i < S.length(); i++) { switch (S.charAt(i)) { case 'N': y += 1; break; case 'E': x += 1; break; case 'W': x -= 1; break; case 'S': y -= 1; break; } } System.out.println(Math.sqrt(x*x + y*y)); } }