結果

問題 No.680 作れる数
ユーザー tailstails
提出日時 2017-06-25 13:31:25
言語 Perl
(5.38.2)
結果
AC  
実行時間 3 ms / 2,000 ms
コード長 248 bytes
コンパイル時間 335 ms
コンパイル使用メモリ 5,480 KB
実行使用メモリ 4,600 KB
最終ジャッジ日時 2023-08-25 23:04:47
合計ジャッジ時間 1,475 ms
ジャッジサーバーID
(参考情報)
judge11 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 2 ms
4,492 KB
testcase_01 AC 2 ms
4,504 KB
testcase_02 AC 2 ms
4,504 KB
testcase_03 AC 2 ms
4,468 KB
testcase_04 AC 2 ms
4,464 KB
testcase_05 AC 2 ms
4,480 KB
testcase_06 AC 2 ms
4,448 KB
testcase_07 AC 2 ms
4,468 KB
testcase_08 AC 2 ms
4,504 KB
testcase_09 AC 3 ms
4,504 KB
testcase_10 AC 3 ms
4,592 KB
testcase_11 AC 2 ms
4,472 KB
testcase_12 AC 3 ms
4,396 KB
testcase_13 AC 2 ms
4,420 KB
testcase_14 AC 2 ms
4,600 KB
testcase_15 AC 2 ms
4,420 KB
testcase_16 AC 3 ms
4,420 KB
testcase_17 AC 3 ms
4,480 KB
testcase_18 AC 2 ms
4,436 KB
testcase_19 AC 2 ms
4,480 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Main.pl syntax OK

ソースコード

diff #

$n=<>;
$tmin=0;
$tmax=1e9+1;

for(;;){
	$s=0;
	$t=$tmid=$tmin+$tmax>>1;
	while($t){
		$s+=$t;
		$t>>=1;
	}
	if($s==$n){
		print("YES");
		exit;
	}
	if($s>$n){
		$tmax=$tmid;
	}else{
		$tmin=$tmid+1;
	}
	if($tmin==$tmax){
		print("NO");
		exit;
	}
}
0