結果
| 問題 |
No.822 Bitwise AND
|
| コンテスト | |
| ユーザー |
maspy
|
| 提出日時 | 2020-02-25 23:59:13 |
| 言語 | Python3 (3.13.1 + numpy 2.2.1 + scipy 1.14.1) |
| 結果 |
AC
|
| 実行時間 | 1,152 ms / 2,000 ms |
| コード長 | 626 bytes |
| コンパイル時間 | 306 ms |
| コンパイル使用メモリ | 12,672 KB |
| 実行使用メモリ | 46,612 KB |
| 最終ジャッジ日時 | 2024-06-25 18:19:14 |
| 合計ジャッジ時間 | 15,547 ms |
|
ジャッジサーバーID (参考情報) |
judge1 / judge2 |
(要ログイン)
| ファイルパターン | 結果 |
|---|---|
| other | AC * 17 |
ソースコード
#!/usr/bin/env python3
# %%
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
# %%
import numpy as np
# %%
N, K = map(int, read().split())
# %%
def solve_fixed_k(N, K):
n = max(N, K).bit_length()
x = np.arange(1 << n + 1, dtype=np.int32)
y = x + K
cond = (x & y == N)
if np.any(cond & (x ^ y >= (1 << n))):
return None
else:
return np.count_nonzero(cond)
# %%
answer = 0
for k in range(K + 1):
x = solve_fixed_k(N, k)
if x is None:
answer = 'INF'
break
answer += x
# %%
print(answer)
maspy