結果

問題 No.1751 Fortune Nim
ユーザー hir355
提出日時 2021-11-19 22:46:01
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 396 bytes
コンパイル時間 134 ms
コンパイル使用メモリ 82,084 KB
実行使用メモリ 107,800 KB
最終ジャッジ日時 2025-01-01 20:43:47
合計ジャッジ時間 3,825 ms
ジャッジサーバーID
(参考情報)
judge3 / judge1
このコードへのチャレンジ
(要ログイン)
ファイルパターン 結果
sample AC * 2
other AC * 16 WA * 14
権限があれば一括ダウンロードができます

ソースコード

diff #

MOD = 998244353
n = int(input())
a = list(map(int, input().split()))
s = sum(a)
g = 0
for x in a:
    g ^= x
if g == 0:
    p = pow(3, s, MOD)
    print((p - 1) * pow(2, -1, MOD) * pow(p, -1, MOD) % MOD)
else:
    ans = 0
    for x in a:
        if g ^ x <= x:
            ans = max(ans, s - (x - (g ^ x)) + 1)
    p = pow(3, ans, MOD)
    print((p + 1) * pow(2, -1, MOD) * pow(p, -1, MOD) % MOD)
0