結果

問題 No.3 ビットすごろく
ユーザー %20%20
提出日時 2017-05-04 01:28:47
言語 Perl
(5.38.2)
結果
AC  
実行時間 55 ms / 5,000 ms
コード長 272 bytes
コンパイル時間 111 ms
コンパイル使用メモリ 5,336 KB
実行使用メモリ 4,948 KB
最終ジャッジ日時 2023-09-14 00:41:14
合計ジャッジ時間 2,298 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,540 KB
testcase_01 AC 2 ms
4,548 KB
testcase_02 AC 3 ms
4,724 KB
testcase_03 AC 10 ms
4,788 KB
testcase_04 AC 4 ms
4,568 KB
testcase_05 AC 24 ms
4,768 KB
testcase_06 AC 10 ms
4,796 KB
testcase_07 AC 6 ms
4,508 KB
testcase_08 AC 20 ms
4,796 KB
testcase_09 AC 34 ms
4,808 KB
testcase_10 AC 46 ms
4,728 KB
testcase_11 AC 31 ms
4,784 KB
testcase_12 AC 24 ms
4,888 KB
testcase_13 AC 8 ms
4,652 KB
testcase_14 AC 48 ms
4,948 KB
testcase_15 AC 54 ms
4,888 KB
testcase_16 AC 49 ms
4,744 KB
testcase_17 AC 53 ms
4,880 KB
testcase_18 AC 7 ms
4,592 KB
testcase_19 AC 55 ms
4,772 KB
testcase_20 AC 4 ms
4,620 KB
testcase_21 AC 3 ms
4,612 KB
testcase_22 AC 44 ms
4,852 KB
testcase_23 AC 55 ms
4,896 KB
testcase_24 AC 54 ms
4,884 KB
testcase_25 AC 54 ms
4,836 KB
testcase_26 AC 3 ms
4,492 KB
testcase_27 AC 9 ms
4,716 KB
testcase_28 AC 49 ms
4,736 KB
testcase_29 AC 32 ms
4,672 KB
testcase_30 AC 3 ms
4,540 KB
testcase_31 AC 3 ms
4,672 KB
testcase_32 AC 28 ms
4,768 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

$N=<>;
$d[@q=1]=2;
while($i=pop@q){
	$t=0;
	$t+=$i>>$_&1for 0..13;
	if($i-$t>=1){
		if($d[$i]+1<($d[$i-$t]||9e9)){
			$d[$i-$t]=$d[$i]+1;
			push@q,$i-$t
		}
	}
	if($i+$t<=$N){
		if($d[$i]+1<($d[$i+$t]||9e9)){
			$d[$i+$t]=$d[$i]+1;
			push@q,$i+$t
		}
	}
}
print$d[$N]-1
0