結果
問題 | No.3 ビットすごろく |
ユーザー | oga00826 |
提出日時 | 2019-06-11 13:29:07 |
言語 | PHP (8.3.4) |
結果 |
WA
|
実行時間 | - |
コード長 | 604 bytes |
コンパイル時間 | 163 ms |
コンパイル使用メモリ | 30,568 KB |
実行使用メモリ | 31,324 KB |
最終ジャッジ日時 | 2024-04-15 20:37:30 |
合計ジャッジ時間 | 2,429 ms |
ジャッジサーバーID (参考情報) |
judge1 / judge5 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 39 ms
31,088 KB |
testcase_01 | AC | 38 ms
30,860 KB |
testcase_02 | AC | 39 ms
31,016 KB |
testcase_03 | AC | 40 ms
30,772 KB |
testcase_04 | AC | 39 ms
30,972 KB |
testcase_05 | AC | 40 ms
30,784 KB |
testcase_06 | AC | 39 ms
30,884 KB |
testcase_07 | AC | 39 ms
31,080 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 41 ms
30,844 KB |
testcase_13 | AC | 40 ms
30,976 KB |
testcase_14 | AC | 40 ms
30,912 KB |
testcase_15 | AC | 40 ms
30,848 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 40 ms
30,988 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | AC | 39 ms
30,732 KB |
testcase_22 | AC | 40 ms
30,760 KB |
testcase_23 | AC | 40 ms
30,840 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | AC | 57 ms
30,852 KB |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | AC | 39 ms
30,844 KB |
testcase_32 | WA | - |
コンパイルメッセージ
No syntax errors detected in Main.php
ソースコード
<?php $goal = trim(fgets(STDIN)); $here = 1; $count = 1; $used_array = [1]; if ($goal == 1) { echo "1"."\n"; exit(); } for ($i=1; $i<$goal; $i++) { $binary = decbin($here); $move = substr_count( $binary, 1 ); $count++; if ( ($here + $move) == $goal ) { break; } elseif ( ($here + $move) > $goal ) { $here = $here - $move; if (array_search($here, $used_array) !== FALSE) { $count = -1; break; } } else { $here = $here + $move; } $used_array[] = $here; // 既に使用した } echo $count."\n";