結果
問題 |
No.113 宝探し
|
ユーザー |
![]() |
提出日時 | 2018-02-09 19:57:35 |
言語 | Java (openjdk 23) |
結果 |
AC
|
実行時間 | 112 ms / 5,000 ms |
コード長 | 428 bytes |
コンパイル時間 | 1,847 ms |
コンパイル使用メモリ | 74,236 KB |
実行使用メモリ | 41,216 KB |
最終ジャッジ日時 | 2024-11-16 21:47:28 |
合計ジャッジ時間 | 5,701 ms |
ジャッジサーバーID (参考情報) |
judge4 / judge2 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
sample | AC * 4 |
other | AC * 23 |
ソースコード
import java.util.*; public class Main { static Scanner sc = new Scanner(System.in); public static void main(String[] args) { String s = sc.next(); int x = 0; int y = 0; for (int i=0; i<s.length(); i++) { if (s.charAt(i)=='N') {y++;} else if (s.charAt(i)=='E') {x++;} else if (s.charAt(i)=='W') {x--;} else if (s.charAt(i)=='S') {y--;} } double ans = Math.sqrt(x*x+y*y); System.out.println(ans); } }