結果

問題 No.47 ポケットを叩くとビスケットが2倍
ユーザー d_nishiyama85d_nishiyama85
提出日時 2016-05-25 10:08:36
言語 PHP
(8.3.4)
結果
WA  
実行時間 -
コード長 341 bytes
コンパイル時間 106 ms
コンパイル使用メモリ 31,132 KB
実行使用メモリ 31,760 KB
最終ジャッジ日時 2024-04-16 16:32:29
合計ジャッジ時間 1,824 ms
ジャッジサーバーID
(参考情報)
judge4 / judge5
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 41 ms
30,932 KB
testcase_02 AC 41 ms
31,016 KB
testcase_03 AC 41 ms
31,164 KB
testcase_04 AC 40 ms
30,924 KB
testcase_05 AC 40 ms
31,212 KB
testcase_06 AC 40 ms
31,088 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 40 ms
31,004 KB
testcase_11 AC 39 ms
31,292 KB
testcase_12 AC 41 ms
31,176 KB
testcase_13 AC 40 ms
31,308 KB
testcase_14 AC 40 ms
31,220 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 41 ms
31,132 KB
testcase_18 AC 40 ms
31,272 KB
testcase_19 AC 40 ms
31,220 KB
testcase_20 AC 40 ms
30,952 KB
testcase_21 WA -
testcase_22 WA -
testcase_23 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php
$N = (int)fgets(STDIN);

$pow = 0;
$digit = 0;
$bin = 1;
$n = $N;
while ($n > 1) {
    $pow++;
    $n = (int)($n/2);
    $bin *= 2;
}

if ($N === $bin) {
    echo "$pow\n";
} else if (($N - $bin) === 1) {
    echo ($por + 1) . "\n";
} else if (($N - $bin) % 2 === 1) {
    echo ($pow + 2) . "\n";
} else {
    echo ($pow + 1) . "\n";
}
0