結果

問題 No.1444 !Andd
ユーザー gew1fw
提出日時 2025-06-12 21:07:34
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 878 bytes
コンパイル時間 170 ms
コンパイル使用メモリ 81,912 KB
実行使用メモリ 80,400 KB
最終ジャッジ日時 2025-06-12 21:09:28
合計ジャッジ時間 9,972 ms
ジャッジサーバーID
(参考情報)
judge5 / judge4
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 3
other WA * 20
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
a_list = list(map(int, input().split()))

s1 = set()
s2 = set()
s1.add(1)

for a in a_list:
    new_s1 = set()
    new_s2 = set()

    # Process elements from s1
    for x in s1:
        # Multiply option
        product = x * a
        if product >= 1024:
            new_s2.add(product % 1024)
        else:
            new_s1.add(product)
        # AND option
        new_and = x & a
        new_s1.add(new_and)
    
    # Process elements from s2
    for a_prev in s2:
        # Multiply option
        if a == 0:
            new_s1.add(0)
        else:
            product_mod = (a_prev * a) % 1024
            new_s2.add(product_mod)
        # AND option
        new_and = a_prev & a
        new_s1.add(new_and)
    
    # Update s1 and s2 for the next iteration
    s1 = new_s1
    s2 = new_s2

    # Output the current count
    print(len(s1) + len(s2))
0