結果

問題 No.939 and or
ユーザー 小野寺健
提出日時 2021-11-08 12:48:58
言語 Ruby
(3.4.1)
結果
WA  
実行時間 -
コード長 407 bytes
コンパイル時間 220 ms
コンパイル使用メモリ 7,296 KB
実行使用メモリ 12,416 KB
最終ジャッジ日時 2024-11-16 00:07:28
合計ジャッジ時間 4,426 ms
ジャッジサーバーID
(参考情報)
judge3 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 25 WA * 5
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

A, B = gets.split(" ").map{|s| s.to_i}

def bitCount(bits)
	bits = (bits & 0x55555555) + ((bits >> 1) & 0x55555555)
	bits = (bits & 0x33333333) + ((bits >> 2) & 0x33333333)
	bits = (bits & 0x0f0f0f0f) + ((bits >> 4) & 0x0f0f0f0f)
	bits = (bits & 0x00ff00ff) + ((bits >> 8) & 0x00ff00ff)
	(bits & 0x0000ffff) + ((bits >> 16) & 0x0000ffff)
end

if A & B != A then
	puts 0
else
	puts 2**(bitCount(A ^ B)-1)
end
0