結果

問題 No.1751 Fortune Nim
ユーザー hir355hir355
提出日時 2021-11-19 22:53:57
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 173 ms / 2,000 ms
コード長 403 bytes
コンパイル時間 559 ms
コンパイル使用メモリ 10,868 KB
実行使用メモリ 29,992 KB
最終ジャッジ日時 2023-08-30 09:51:34
合計ジャッジ時間 5,388 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 15 ms
7,820 KB
testcase_01 AC 15 ms
7,792 KB
testcase_02 AC 15 ms
7,760 KB
testcase_03 AC 15 ms
7,812 KB
testcase_04 AC 15 ms
7,792 KB
testcase_05 AC 15 ms
7,792 KB
testcase_06 AC 16 ms
7,828 KB
testcase_07 AC 15 ms
7,764 KB
testcase_08 AC 124 ms
23,344 KB
testcase_09 AC 117 ms
22,616 KB
testcase_10 AC 105 ms
20,348 KB
testcase_11 AC 142 ms
27,204 KB
testcase_12 AC 93 ms
19,720 KB
testcase_13 AC 152 ms
27,040 KB
testcase_14 AC 115 ms
22,316 KB
testcase_15 AC 117 ms
22,424 KB
testcase_16 AC 82 ms
25,176 KB
testcase_17 AC 71 ms
22,312 KB
testcase_18 AC 91 ms
27,456 KB
testcase_19 AC 65 ms
21,772 KB
testcase_20 AC 99 ms
29,088 KB
testcase_21 AC 77 ms
24,008 KB
testcase_22 AC 95 ms
29,872 KB
testcase_23 AC 86 ms
27,068 KB
testcase_24 AC 168 ms
29,888 KB
testcase_25 AC 169 ms
29,992 KB
testcase_26 AC 173 ms
29,844 KB
testcase_27 AC 168 ms
29,816 KB
testcase_28 AC 101 ms
29,888 KB
testcase_29 AC 104 ms
29,864 KB
testcase_30 AC 104 ms
29,904 KB
testcase_31 AC 104 ms
29,860 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 = 10 ** 18
    for x in a:
        if g ^ x <= x:
            ans = min(ans, s - (x - (g ^ x)) + 1)
    p = pow(3, ans, MOD)
    print((p + 1) * pow(2, -1, MOD) * pow(p, -1, MOD) % MOD)
0