結果
問題 | No.3 ビットすごろく |
ユーザー | oga00826 |
提出日時 | 2019-06-11 12:57:04 |
言語 | PHP (8.3.4) |
結果 |
WA
|
実行時間 | - |
コード長 | 654 bytes |
コンパイル時間 | 238 ms |
コンパイル使用メモリ | 31,004 KB |
実行使用メモリ | 31,576 KB |
最終ジャッジ日時 | 2024-04-15 20:36:00 |
合計ジャッジ時間 | 2,786 ms |
ジャッジサーバーID (参考情報) |
judge5 / judge1 |
(要ログイン)
テストケース
テストケース表示入力 | 結果 | 実行時間 実行使用メモリ |
---|---|---|
testcase_00 | AC | 43 ms
30,760 KB |
testcase_01 | AC | 52 ms
31,004 KB |
testcase_02 | AC | 40 ms
31,132 KB |
testcase_03 | AC | 39 ms
31,128 KB |
testcase_04 | AC | 39 ms
30,768 KB |
testcase_05 | AC | 41 ms
30,948 KB |
testcase_06 | AC | 40 ms
31,076 KB |
testcase_07 | AC | 39 ms
30,936 KB |
testcase_08 | WA | - |
testcase_09 | WA | - |
testcase_10 | WA | - |
testcase_11 | WA | - |
testcase_12 | AC | 40 ms
30,912 KB |
testcase_13 | AC | 41 ms
30,812 KB |
testcase_14 | AC | 41 ms
30,944 KB |
testcase_15 | AC | 40 ms
30,932 KB |
testcase_16 | WA | - |
testcase_17 | WA | - |
testcase_18 | AC | 40 ms
30,760 KB |
testcase_19 | WA | - |
testcase_20 | WA | - |
testcase_21 | AC | 40 ms
31,080 KB |
testcase_22 | AC | 40 ms
30,772 KB |
testcase_23 | AC | 39 ms
30,976 KB |
testcase_24 | WA | - |
testcase_25 | WA | - |
testcase_26 | AC | 40 ms
30,748 KB |
testcase_27 | WA | - |
testcase_28 | WA | - |
testcase_29 | WA | - |
testcase_30 | WA | - |
testcase_31 | AC | 39 ms
30,760 KB |
testcase_32 | WA | - |
コンパイルメッセージ
No syntax errors detected in Main.php
ソースコード
<?php $goal = trim(fgets(STDIN)); $here = 1; $count = 1; $used_array = []; for ($i=1; $i<=$goal; $i++) { $i = $here; // 現在地に書き換え $binary = decbin($i); $move = substr_count( $binary, 1 ); $count++; if ($goal == 1) { $count--; break; } elseif ( ($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[] = $i; // 既に使用した } echo $count."\n";