結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 39 ms
31,256 KB
testcase_02 AC 41 ms
31,184 KB
testcase_03 AC 40 ms
31,548 KB
testcase_04 AC 40 ms
31,244 KB
testcase_05 AC 41 ms
31,368 KB
testcase_06 AC 40 ms
31,164 KB
testcase_07 WA -
testcase_08 WA -
testcase_09 WA -
testcase_10 AC 41 ms
31,248 KB
testcase_11 AC 40 ms
31,336 KB
testcase_12 AC 41 ms
31,304 KB
testcase_13 AC 39 ms
31,504 KB
testcase_14 AC 40 ms
31,304 KB
testcase_15 WA -
testcase_16 WA -
testcase_17 AC 40 ms
31,296 KB
testcase_18 AC 40 ms
31,084 KB
testcase_19 AC 40 ms
31,188 KB
testcase_20 AC 41 ms
31,224 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) % 2 === 1) {
    echo ($pow + 2) . "\n";
} else {
    echo ($pow + 1) . "\n";
}
0