結果

問題 No.1289 RNG and OR
ユーザー Kiri8128Kiri8128
提出日時 2020-11-14 02:42:55
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 2,102 bytes
コンパイル時間 220 ms
コンパイル使用メモリ 87,012 KB
実行使用メモリ 104,956 KB
最終ジャッジ日時 2023-09-30 04:42:42
合計ジャッジ時間 3,236 ms
ジャッジサーバーID
(参考情報)
judge11 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 WA -
testcase_01 AC 59 ms
71,024 KB
testcase_02 AC 58 ms
71,380 KB
testcase_03 WA -
testcase_04 AC 70 ms
71,288 KB
testcase_05 WA -
testcase_06 AC 62 ms
71,136 KB
testcase_07 WA -
testcase_08 AC 68 ms
71,352 KB
testcase_09 WA -
testcase_10 AC 69 ms
75,844 KB
testcase_11 WA -
testcase_12 AC 71 ms
75,252 KB
testcase_13 WA -
testcase_14 AC 80 ms
76,792 KB
testcase_15 WA -
testcase_16 AC 90 ms
76,548 KB
testcase_17 WA -
testcase_18 AC 144 ms
83,480 KB
testcase_19 WA -
testcase_20 AC 349 ms
104,956 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

def or_convolution(A, B):
    n = max(len(A), len(B))
    X = [0] * (1 << (n - 1).bit_length())
    for i, a in enumerate(A):
        for j, b in enumerate(B):
            X[i|j] += a * b
    return X
def and_convolution(A, B):
    n = max(len(A), len(B))
    X = [0] * (1 << (n - 1).bit_length())
    for i, a in enumerate(A):
        for j, b in enumerate(B):
            X[i&j] += a * b
    return X

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 mobius_bit(L0): # zeta_bit の逆変換
    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)[::-1]:
            if j >> i & 1:
                L[j] -= L[j^(1<<i)]
    return L
def zeta_bit_inv(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)[::-1]:
            if j >> i & 1:
                L[j^(1<<i)] += L[j]
    return L
def mobius_bit_inv(L0): # zeta_bit_inv の逆変換
    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^(1<<i)] -= L[j]
    return L
def popcount_parity(x):
    x ^= x >> 1
    x ^= x >> 2
    x ^= x >> 4
    x ^= x >> 8
    x ^= x >> 16
    return x & 1
def r(a):
    for i in range(1, 10001):
        if i and a * i % P <= 10000:
            return str(a*i%P) + "/" + str(i)
        if i and -a * i % P <= 10000:
            return str(-(-a*i%P)) + "/" + str(i)
    return a
P = 998244353
N = int(input())
A = [int(a) for a in input().split()]
S = sum(A)
iS = pow(S, P - 2, P)
A = [a * iS % P for a in A]
B = zeta_bit(A)
ans = 0
for i, b in enumerate(B[:-1]):
    if popcount_parity(i):
        ans += pow(B[-1] - b, P - 2, P)
    else:
        ans -= pow(B[-1] - b, P - 2, P)
print(ans % P)
0