結果

問題 No.680 作れる数
ユーザー tailstails
提出日時 2017-06-25 13:31:25
言語 Perl
(5.40.0)
結果
AC  
実行時間 5 ms / 2,000 ms
コード長 248 bytes
コンパイル時間 216 ms
コンパイル使用メモリ 6,820 KB
実行使用メモリ 5,248 KB
最終ジャッジ日時 2024-12-24 10:45:46
合計ジャッジ時間 1,222 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
other AC * 20
権限があれば一括ダウンロードができます
コンパイルメッセージ
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