結果
| 問題 | 
                            No.1751 Fortune Nim
                             | 
                    
| コンテスト | |
| ユーザー | 
                             hir355
                         | 
                    
| 提出日時 | 2021-11-19 22:46:19 | 
| 言語 | Python3  (3.13.1 + numpy 2.2.1 + scipy 1.14.1)  | 
                    
| 結果 | 
                             
                                WA
                                 
                             
                            
                         | 
                    
| 実行時間 | - | 
| コード長 | 396 bytes | 
| コンパイル時間 | 384 ms | 
| コンパイル使用メモリ | 12,416 KB | 
| 実行使用メモリ | 32,352 KB | 
| 最終ジャッジ日時 | 2025-01-01 20:46:41 | 
| 合計ジャッジ時間 | 4,992 ms | 
| 
                            ジャッジサーバーID (参考情報)  | 
                        judge5 / judge3 | 
(要ログイン)
| ファイルパターン | 結果 | 
|---|---|
| sample | AC * 2 | 
| other | AC * 16 WA * 14 | 
ソースコード
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)
            
            
            
        
            
hir355