結果

問題 No.1751 Fortune Nim
ユーザー hir355hir355
提出日時 2021-11-19 22:46:01
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 396 bytes
コンパイル時間 299 ms
コンパイル使用メモリ 87,280 KB
実行使用メモリ 104,456 KB
最終ジャッジ日時 2023-08-30 09:39:08
合計ジャッジ時間 5,392 ms
ジャッジサーバーID
(参考情報)
judge14 / judge15
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,276 KB
testcase_01 AC 72 ms
71,320 KB
testcase_02 AC 73 ms
71,292 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 71 ms
71,248 KB
testcase_06 AC 71 ms
71,248 KB
testcase_07 AC 71 ms
71,528 KB
testcase_08 WA -
testcase_09 WA -
testcase_10 WA -
testcase_11 WA -
testcase_12 WA -
testcase_13 WA -
testcase_14 WA -
testcase_15 WA -
testcase_16 AC 106 ms
101,768 KB
testcase_17 AC 99 ms
96,156 KB
testcase_18 AC 117 ms
99,880 KB
testcase_19 AC 99 ms
96,004 KB
testcase_20 AC 121 ms
100,088 KB
testcase_21 AC 103 ms
99,080 KB
testcase_22 AC 120 ms
100,100 KB
testcase_23 AC 112 ms
104,456 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 123 ms
100,580 KB
testcase_29 AC 121 ms
100,328 KB
testcase_30 AC 123 ms
100,680 KB
testcase_31 AC 122 ms
100,396 KB
権限があれば一括ダウンロードができます

ソースコード

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