結果
| 問題 |
No.113 宝探し
|
| コンテスト | |
| ユーザー |
|
| 提出日時 | 2019-02-14 21:59:28 |
| 言語 | Java (openjdk 23) |
| 結果 |
AC
|
| 実行時間 | 130 ms / 5,000 ms |
| コード長 | 674 bytes |
| コンパイル時間 | 3,439 ms |
| コンパイル使用メモリ | 74,364 KB |
| 実行使用メモリ | 41,400 KB |
| 最終ジャッジ日時 | 2024-11-16 22:01:44 |
| 合計ジャッジ時間 | 7,264 ms |
|
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| sample | AC * 4 |
| other | AC * 23 |
ソースコード
import java.util.*;
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 y--;
}
System.out.println(calcEuclidDistance(0,0,x,y));
}
static int calcManhatDistance (int x1, int y1, int x2, int y2) {
int d = Math.abs(x1-x2)+Math.abs(y1-y2);
return d;
}
static double calcEuclidDistance (double x1, double y1, double x2, double y2) {
double d = Math.sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
return d;
}
}