結果

問題 No.3 ビットすごろく
ユーザー しのっちしのっち
提出日時 2019-06-11 13:58:50
言語 PHP
(8.3.4)
結果
TLE  
実行時間 -
コード長 427 bytes
コンパイル時間 1,289 ms
コンパイル使用メモリ 31,120 KB
実行使用メモリ 36,112 KB
最終ジャッジ日時 2024-04-15 20:39:02
合計ジャッジ時間 6,764 ms
ジャッジサーバーID
(参考情報)
judge4 / judge1
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 39 ms
31,036 KB
testcase_01 AC 37 ms
31,116 KB
testcase_02 TLE -
testcase_03 -- -
testcase_04 -- -
testcase_05 -- -
testcase_06 -- -
testcase_07 -- -
testcase_08 -- -
testcase_09 -- -
testcase_10 -- -
testcase_11 -- -
testcase_12 -- -
testcase_13 -- -
testcase_14 -- -
testcase_15 -- -
testcase_16 -- -
testcase_17 -- -
testcase_18 -- -
testcase_19 -- -
testcase_20 -- -
testcase_21 -- -
testcase_22 -- -
testcase_23 -- -
testcase_24 -- -
testcase_25 -- -
testcase_26 -- -
testcase_27 -- -
testcase_28 -- -
testcase_29 -- -
testcase_30 -- -
testcase_31 -- -
testcase_32 -- -
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
      $n = intval(trim(fgets(STDIN)));
      $grid= 1;
      $counter= 1;
      
      if ($n == 1) {
        echo $counter;
        die;
      }
      while ($grid != 0) {
        $counter++;
        $steps = mb_substr_count(decbin($grid), 1);
        $grid += $steps;
        if ($grid == $n) {
          echo $counter;
          break;
        } elseif ($grid > $n) {
          $grid -= ($steps * 2);
        }
      }
0