結果
問題 |
No.113 宝探し
|
ユーザー |
![]() |
提出日時 | 2015-12-11 22:06:40 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 47 ms / 5,000 ms |
コード長 | 782 bytes |
コンパイル時間 | 2,083 ms |
コンパイル使用メモリ | 73,448 KB |
実行使用メモリ | 36,988 KB |
最終ジャッジ日時 | 2024-11-16 21:04:36 |
合計ジャッジ時間 | 4,109 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) { BufferedReader buff = new BufferedReader(new InputStreamReader(System.in)); try { String line = buff.readLine(); int x = 0, y = 0; for (int i = 0; i < line.length(); ++i) { if (line.charAt(i) == 'N') { ++y; } else if (line.charAt(i) == 'E') { ++x; } else if (line.charAt(i) == 'S') { --y; } else { --x; } } double ans = Math.sqrt((Math.pow(x, 2) + Math.pow(y, 2))); System.out.println(ans); } catch (NumberFormatException e) { e.getStackTrace(); } catch (IOException e) { e.getStackTrace(); } catch (Exception e) { e.getStackTrace(); } } }