結果

問題 No.1444 !Andd
ユーザー convexineqconvexineq
提出日時 2021-03-26 22:30:13
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 358 ms / 2,000 ms
コード長 518 bytes
コンパイル時間 1,248 ms
コンパイル使用メモリ 86,888 KB
実行使用メモリ 79,324 KB
最終ジャッジ日時 2023-08-19 09:03:09
合計ジャッジ時間 7,990 ms
ジャッジサーバーID
(参考情報)
judge13 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 64 ms
75,644 KB
testcase_01 AC 65 ms
75,640 KB
testcase_02 AC 63 ms
75,756 KB
testcase_03 AC 160 ms
77,704 KB
testcase_04 AC 123 ms
77,372 KB
testcase_05 AC 157 ms
78,176 KB
testcase_06 AC 123 ms
77,484 KB
testcase_07 AC 111 ms
77,196 KB
testcase_08 AC 191 ms
77,920 KB
testcase_09 AC 138 ms
77,588 KB
testcase_10 AC 124 ms
77,880 KB
testcase_11 AC 136 ms
77,728 KB
testcase_12 AC 211 ms
77,808 KB
testcase_13 AC 262 ms
78,328 KB
testcase_14 AC 170 ms
78,240 KB
testcase_15 AC 263 ms
78,204 KB
testcase_16 AC 358 ms
79,052 KB
testcase_17 AC 250 ms
79,324 KB
testcase_18 AC 354 ms
79,040 KB
testcase_19 AC 358 ms
78,924 KB
testcase_20 AC 351 ms
79,096 KB
testcase_21 AC 355 ms
78,832 KB
testcase_22 AC 352 ms
78,956 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

n = int(input())
*a, = map(int,input().split())
M = 1024
dp = [0]*(2*M)
dp[1] = 1
for ai in a:
    if ai == 0:
        dp = [0]*(2*M)
        dp[0] = 1
        print(1)
        continue

    ndp = [0]*(2*M)
    for i in range(M):
        if dp[i]==0: continue
        ndp[i&ai] |= 1
        if i*ai < M:
            ndp[i*ai] |= 1
        else:
            ndp[M+(i*ai)%M] += 1
    for i in range(M,2*M):
        if dp[i]:
            ndp[M+(i*ai)%M] += dp[i]
            ndp[i&ai] |= 1
    dp = ndp
    print(sum(dp))
0