結果

問題 No.1751 Fortune Nim
ユーザー chineristACchineristAC
提出日時 2021-11-19 22:44:30
言語 PyPy3
(7.3.15)
結果
RE  
実行時間 -
コード長 1,963 bytes
コンパイル時間 560 ms
コンパイル使用メモリ 87,280 KB
実行使用メモリ 121,580 KB
最終ジャッジ日時 2023-08-30 09:36:44
合計ジャッジ時間 8,577 ms
ジャッジサーバーID
(参考情報)
judge13 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 RE -
testcase_01 AC 128 ms
82,800 KB
testcase_02 RE -
testcase_03 RE -
testcase_04 RE -
testcase_05 AC 129 ms
82,804 KB
testcase_06 AC 129 ms
82,976 KB
testcase_07 AC 129 ms
82,968 KB
testcase_08 RE -
testcase_09 RE -
testcase_10 RE -
testcase_11 RE -
testcase_12 RE -
testcase_13 RE -
testcase_14 RE -
testcase_15 RE -
testcase_16 AC 170 ms
107,456 KB
testcase_17 AC 166 ms
101,592 KB
testcase_18 AC 188 ms
110,552 KB
testcase_19 AC 166 ms
100,844 KB
testcase_20 AC 176 ms
114,404 KB
testcase_21 AC 167 ms
103,940 KB
testcase_22 AC 176 ms
114,240 KB
testcase_23 AC 173 ms
110,076 KB
testcase_24 RE -
testcase_25 RE -
testcase_26 RE -
testcase_27 RE -
testcase_28 AC 176 ms
114,644 KB
testcase_29 AC 176 ms
114,780 KB
testcase_30 AC 176 ms
114,600 KB
testcase_31 AC 177 ms
114,680 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N = 2*10**5
mod = 998244353
g1 = [1]*(N+1) # 元テーブル
g2 = [1]*(N+1) #逆元テーブル
inverse = [1]*(N+1) #逆元テーブル計算用テーブル

for i in range( 2, N + 1 ):
    g1[i]=( ( g1[i-1] * i ) % mod )
    inverse[i]=( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2[i]=( (g2[i-1] * inverse[i]) % mod )
inverse[0]=0

def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

def fwt(n,A):
    assert len(A) == 2**n
    for i in range(n):
        t = 2**i
        for j in range(2**n):
            if j&t==0:
                A[j] += A[j|t]
    return A

def ifwt(n,A):
    assert len(A) == 2**n
    for i in range(n):
        t = 2**i
        for j in range(2**n):
            if j&t==0:
                A[j] -= A[j|t]
    return A

inv = pow(1024,mod-2,mod)
 
def _fourier(f, inverse = False):
    f = f[:]
    n = (len(f) - 1).bit_length()
    for d in range(n):
        for U in range(1 << n):
            if not U >> d & 1:
                s, t = f[U], f[U | 1 << d]
                f[U], f[U | 1 << d] = (s + t)%mod, (s - t)%mod
    if inverse:
        f = [v *inv % mod for v in f]
    return f
 
def convolution(f, g):
    return _fourier([a * b  % mod for a, b in zip(_fourier(f), _fourier(g))], inverse = 1)

import sys,random,bisect
from collections import deque,defaultdict
from heapq import heapify,heappop,heappush
from itertools import permutations
from math import log,gcd

input = lambda :sys.stdin.readline()
mi = lambda :map(int,input().split())
li = lambda :list(mi())

N = int(input())
A = li()

S = sum(A)

G = 0
for a in A:
    G ^= a

assert G==0
if G==0:
    n = S
    res = (1-pow(inverse[3],n,mod)) * pow(2,mod-2,mod) % mod
    print(res)

else:
    n = 10**100
    for i in range(N):
        if A[i]^G <= A[i]:
            tmp = S - (A[i]-A[i]^G) + 1
            n = min(n,tmp)
    res = (pow(inverse[3],n,mod)+1) * pow(2,mod-2,mod) % mod
    print(res)
0