結果

問題 No.3 ビットすごろく
ユーザー jake_tarojake_taro
提出日時 2015-09-07 15:20:14
言語 PHP
(8.3.4)
結果
WA  
実行時間 -
コード長 443 bytes
コンパイル時間 67 ms
コンパイル使用メモリ 18,808 KB
実行使用メモリ 19,172 KB
最終ジャッジ日時 2023-09-26 10:00:18
合計ジャッジ時間 2,519 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
18,904 KB
testcase_01 AC 16 ms
18,696 KB
testcase_02 AC 28 ms
19,004 KB
testcase_03 AC 43 ms
18,888 KB
testcase_04 AC 16 ms
18,936 KB
testcase_05 AC 47 ms
18,964 KB
testcase_06 AC 42 ms
19,004 KB
testcase_07 AC 16 ms
18,988 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 AC 46 ms
19,036 KB
testcase_13 AC 45 ms
18,996 KB
testcase_14 AC 49 ms
18,908 KB
testcase_15 AC 46 ms
19,000 KB
testcase_16 WA -
testcase_17 WA -
testcase_18 AC 16 ms
18,920 KB
testcase_19 WA -
testcase_20 WA -
testcase_21 AC 15 ms
18,948 KB
testcase_22 AC 46 ms
18,972 KB
testcase_23 AC 46 ms
18,980 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 WA -
testcase_29 WA -
testcase_30 WA -
testcase_31 AC 16 ms
18,960 KB
testcase_32 WA -
権限があれば一括ダウンロードができます
コンパイルメッセージ
No syntax errors detected in Main.php

ソースコード

diff #

<?php

$N = (int)trim(fgets(STDIN)); // マス数N
$start = 1; //スタート地点
$count = 0; //移動回数
do{
	if($N == 1){
		echo 0,PHP_EOL;
		exit;
	}
	$number_2 = decbin($start); //2進数表記
	$shift = substr_count($number_2, "1");
	$start += $shift;
	if($start > $N){
		$start -= 2 * $shift;
	}
	$count++;
	# echo $start, PHP_EOL;
	if($count > 100000){
		echo -1, PHP_EOL;
		exit;
	}
}while($start < $N);

echo $count + 1, PHP_EOL;
0