結果

問題 No.822 Bitwise AND
ユーザー yuruhiyayuruhiya
提出日時 2020-09-01 17:45:35
言語 Ruby
(3.3.0)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 369 bytes
コンパイル時間 624 ms
コンパイル使用メモリ 11,284 KB
実行使用メモリ 15,436 KB
最終ジャッジ日時 2023-09-08 01:17:19
合計ジャッジ時間 3,295 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 87 ms
15,292 KB
testcase_02 AC 82 ms
15,052 KB
testcase_03 AC 80 ms
15,316 KB
testcase_04 AC 95 ms
15,436 KB
testcase_05 AC 80 ms
15,032 KB
testcase_06 AC 81 ms
15,032 KB
testcase_07 AC 94 ms
15,176 KB
testcase_08 AC 81 ms
15,324 KB
testcase_09 AC 80 ms
15,256 KB
testcase_10 AC 82 ms
15,272 KB
testcase_11 AC 85 ms
15,068 KB
testcase_12 AC 79 ms
15,140 KB
testcase_13 AC 80 ms
15,272 KB
testcase_14 AC 79 ms
15,156 KB
testcase_15 AC 83 ms
15,304 KB
testcase_16 AC 80 ms
15,144 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 && 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