結果

問題 No.113 宝探し
ユーザー mondomondo
提出日時 2019-08-06 10:53:00
言語 PHP
(8.3.4)
結果
AC  
実行時間 39 ms / 5,000 ms
コード長 235 bytes
コンパイル時間 851 ms
コンパイル使用メモリ 30,804 KB
実行使用メモリ 31,412 KB
最終ジャッジ日時 2024-04-28 08:24:13
合計ジャッジ時間 2,593 ms
ジャッジサーバーID
(参考情報)
judge3 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 33 ms
31,016 KB
testcase_01 AC 34 ms
31,052 KB
testcase_02 AC 35 ms
31,288 KB
testcase_03 AC 36 ms
30,996 KB
testcase_04 AC 35 ms
31,288 KB
testcase_05 AC 37 ms
31,288 KB
testcase_06 AC 35 ms
31,260 KB
testcase_07 AC 36 ms
31,324 KB
testcase_08 AC 36 ms
31,144 KB
testcase_09 AC 36 ms
31,316 KB
testcase_10 AC 36 ms
31,324 KB
testcase_11 AC 36 ms
31,300 KB
testcase_12 AC 35 ms
31,052 KB
testcase_13 AC 34 ms
31,408 KB
testcase_14 AC 37 ms
31,268 KB
testcase_15 AC 35 ms
31,028 KB
testcase_16 AC 35 ms
31,144 KB
testcase_17 AC 34 ms
31,412 KB
testcase_18 AC 35 ms
31,060 KB
testcase_19 AC 34 ms
31,156 KB
testcase_20 AC 35 ms
31,136 KB
testcase_21 AC 33 ms
31,260 KB
testcase_22 AC 39 ms
31,384 KB
testcase_23 AC 38 ms
31,000 KB
testcase_24 AC 37 ms
31,348 KB
testcase_25 AC 37 ms
31,024 KB
testcase_26 AC 35 ms
31,280 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
$s = trim(fgets(STDIN));
$x = 0;
$y = 0;
for($i = 0; $i < strlen($s); $i++) {
  $n = substr($s, $i, 1);
  if($n == 'N') $y++;
  if($n == 'E') $x++;
  if($n == 'W') $x--;
  if($n == 'S') $y--;
}
print(sqrt(pow($x,2) + pow($y,2)));
0