結果

問題 No.1751 Fortune Nim
ユーザー hir355hir355
提出日時 2021-11-19 22:46:19
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
WA  
実行時間 -
コード長 396 bytes
コンパイル時間 1,132 ms
コンパイル使用メモリ 10,664 KB
実行使用メモリ 29,964 KB
最終ジャッジ日時 2023-08-30 09:39:46
合計ジャッジ時間 5,468 ms
ジャッジサーバーID
(参考情報)
judge15 / judge12
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,692 KB
testcase_01 AC 16 ms
7,736 KB
testcase_02 AC 17 ms
7,860 KB
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 16 ms
7,860 KB
testcase_06 AC 16 ms
7,828 KB
testcase_07 AC 16 ms
7,912 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 86 ms
25,132 KB
testcase_17 AC 75 ms
22,332 KB
testcase_18 AC 97 ms
27,424 KB
testcase_19 AC 73 ms
21,616 KB
testcase_20 AC 102 ms
29,068 KB
testcase_21 AC 82 ms
24,040 KB
testcase_22 AC 101 ms
29,840 KB
testcase_23 AC 90 ms
26,848 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 108 ms
29,956 KB
testcase_29 AC 106 ms
29,892 KB
testcase_30 AC 106 ms
29,956 KB
testcase_31 AC 109 ms
29,764 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