結果

問題 No.822 Bitwise AND
ユーザー kamojirokamojiro
提出日時 2019-04-26 23:19:23
言語 Python3
(3.11.6 + numpy 1.26.0 + scipy 1.11.3)
結果
WA  
(最新)
AC  
(最初)
実行時間 -
コード長 712 bytes
コンパイル時間 470 ms
コンパイル使用メモリ 10,772 KB
実行使用メモリ 8,336 KB
最終ジャッジ日時 2023-09-08 01:11:48
合計ジャッジ時間 1,467 ms
ジャッジサーバーID
(参考情報)
judge12 / judge14
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 16 ms
8,324 KB
testcase_02 AC 16 ms
8,336 KB
testcase_03 AC 16 ms
8,204 KB
testcase_04 AC 21 ms
8,304 KB
testcase_05 AC 16 ms
8,328 KB
testcase_06 AC 16 ms
8,236 KB
testcase_07 AC 21 ms
8,308 KB
testcase_08 AC 16 ms
8,104 KB
testcase_09 AC 16 ms
8,260 KB
testcase_10 AC 16 ms
8,200 KB
testcase_11 AC 16 ms
8,312 KB
testcase_12 AC 16 ms
8,152 KB
testcase_13 AC 16 ms
8,328 KB
testcase_14 AC 16 ms
8,148 KB
testcase_15 AC 17 ms
8,236 KB
testcase_16 AC 16 ms
8,140 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

from itertools import product
def adic(n):
    Ret = [0]*18
    for i in range(18):
        if n%2 == 0:
            Ret[i] = 0
        else:
            Ret[i] = 1
        n //= 2
    return Ret

N, K = map( int, input().split())
check = 2**18
Nadic = adic(N)
for i in range(18):
    if Nadic[i] == 0:
        check -= 2**i
if check <= K:
    print("INF")
else:
    D = [2**i for i in range(18) if Nadic[i] == 0 and 2**i <= K]
    ans = 0
    P = len(D)
    for F in product( range(3), repeat = P):
        c = 0
        for i in range(P):
            if F[i] == 1:
                c += D[i]
            if F[i] == 2:
                c -= D[i]
        if c <= K and c >= 0:
            ans += 1

    print(ans)
0