結果
問題 |
No.113 宝探し
|
ユーザー |
![]() |
提出日時 | 2016-11-05 02:56:17 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 126 ms / 5,000 ms |
コード長 | 764 bytes |
コンパイル時間 | 2,414 ms |
コンパイル使用メモリ | 73,900 KB |
実行使用メモリ | 41,444 KB |
最終ジャッジ日時 | 2024-11-16 21:28:37 |
合計ジャッジ時間 | 6,125 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge4 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 23 |
ソースコード
import java.util.Scanner; public class Main { public static void main(String[] args) { Scanner sc = new Scanner(System.in); String direction = sc.next(); int x = 0; int y = 0; for (int i = 0; i < direction.length(); i++) { switch (direction.charAt(i)) { case 'N' : y++; break; case 'E' : x++; break; case 'W' : x--; break; case 'S' : y--; break; } } double distance = Math.sqrt((x * x) + (y * y)); System.out.println(distance); } }