結果

問題 No.822 Bitwise AND
ユーザー yuruhiyayuruhiya
提出日時 2021-01-31 09:28:50
言語 Ruby
(3.3.0)
結果
WA  
実行時間 -
コード長 373 bytes
コンパイル時間 65 ms
コンパイル使用メモリ 11,440 KB
実行使用メモリ 15,420 KB
最終ジャッジ日時 2023-09-11 04:31:10
合計ジャッジ時間 6,878 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 85 ms
15,244 KB
testcase_02 AC 85 ms
15,196 KB
testcase_03 AC 85 ms
15,272 KB
testcase_04 AC 100 ms
15,256 KB
testcase_05 AC 88 ms
15,240 KB
testcase_06 AC 91 ms
15,152 KB
testcase_07 AC 101 ms
15,196 KB
testcase_08 AC 88 ms
15,080 KB
testcase_09 AC 85 ms
15,108 KB
testcase_10 AC 87 ms
15,256 KB
testcase_11 AC 86 ms
15,124 KB
testcase_12 AC 88 ms
15,080 KB
testcase_13 AC 86 ms
15,236 KB
testcase_14 AC 87 ms
15,344 KB
testcase_15 AC 102 ms
15,260 KB
testcase_16 AC 86 ms
15,280 KB
権限があれば一括ダウンロードができます
コンパイルメッセージ
Syntax OK

ソースコード

diff #

n, k = gets.split.map &:to_i
if k == 0
	puts 1
else
	if n + 1 <= k
		puts 'INF'
	else
		bits = (0..30).select { |i| 2**i <= k * 4 && n[i] == 0 }.map { 2**_1 }
		puts [0, 1, 2].repeated_permutation(bits.size).count { |i|
				x = i.each_with_index.sum { _1 == 1 ? bits[_2] : 0 }
				y = i.each_with_index.sum { _1 == 2 ? bits[_2] : 0 }
				(0..k) === y - x
		     }
	end
end
0