結果
問題 |
No.3 ビットすごろく
|
ユーザー |
![]() |
提出日時 | 2015-06-29 15:47:50 |
言語 | PHP (843.2) |
結果 |
TLE
|
実行時間 | - |
コード長 | 494 bytes |
コンパイル時間 | 3,140 ms |
コンパイル使用メモリ | 30,800 KB |
実行使用メモリ | 36,240 KB |
最終ジャッジ日時 | 2024-07-07 21:10:03 |
合計ジャッジ時間 | 9,976 ms |
ジャッジサーバーID (参考情報) |
judge2 / judge1 |
(要ログイン)
ファイルパターン | 結果 |
---|---|
other | AC * 3 TLE * 1 -- * 29 |
コンパイルメッセージ
No syntax errors detected in Main.php
ソースコード
<?php $n = trim(fgets(STDIN)); $pos = 1; // 現在位置 $count = 1; // 移動回数 $visited = 0; // 訪問済位置 while($n != 1){ if (move($pos) == $n ){ $count++; break; } elseif (move($pos) > $n){ $pos -= substr_count(decbin($pos),1,0); if ($pos == $visited){ $count = -1; break; } $visited = $pos; $count++; } $pos = move($pos); $count++; } echo $count .PHP_EOL; function move($param){ $param += substr_count(decbin($param),1,0); return $param; }