結果

問題 No.1289 RNG and OR
ユーザー Kiri8128Kiri8128
提出日時 2020-11-14 02:48:40
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 397 ms / 2,000 ms
コード長 624 bytes
コンパイル時間 334 ms
コンパイル使用メモリ 87,168 KB
実行使用メモリ 105,168 KB
最終ジャッジ日時 2023-09-30 04:43:22
合計ジャッジ時間 3,812 ms
ジャッジサーバーID
(参考情報)
judge14 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,468 KB
testcase_01 AC 76 ms
71,380 KB
testcase_02 AC 74 ms
71,380 KB
testcase_03 AC 76 ms
71,396 KB
testcase_04 AC 77 ms
71,320 KB
testcase_05 AC 77 ms
71,452 KB
testcase_06 AC 77 ms
71,548 KB
testcase_07 AC 77 ms
71,444 KB
testcase_08 AC 76 ms
71,640 KB
testcase_09 AC 76 ms
71,156 KB
testcase_10 AC 82 ms
75,804 KB
testcase_11 AC 84 ms
75,724 KB
testcase_12 AC 84 ms
75,708 KB
testcase_13 AC 92 ms
76,800 KB
testcase_14 AC 93 ms
76,796 KB
testcase_15 AC 98 ms
76,800 KB
testcase_16 AC 105 ms
76,708 KB
testcase_17 AC 126 ms
79,528 KB
testcase_18 AC 166 ms
83,632 KB
testcase_19 AC 241 ms
92,436 KB
testcase_20 AC 397 ms
105,168 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def zeta_bit(L0):
    k = (len(L0) - 1).bit_length()
    n = 1 << k
    L = L0[:] + [0] * (n - len(L0))
    for i in range(k):
        for j in range(n):
            if j >> i & 1:
                L[j] += L[j^(1<<i)]
    return L
def popcount_parity(x):
    x ^= x >> 1
    x ^= x >> 2
    x ^= x >> 4
    x ^= x >> 8
    x ^= x >> 16
    return x & 1

P = 998244353
N = int(input())
A = [int(a) for a in input().split()]
iS = pow(sum(A), P - 2, P)
B = zeta_bit([a * iS % P for a in A])
ans = 0
for i, b in enumerate(B[:-1]):
    ans += pow(B[-1] - b, P - 2, P) * (1 if popcount_parity(i) else -1)
print(ans * (-1) ** N % P)
0