結果

問題 No.1751 Fortune Nim
ユーザー hir355hir355
提出日時 2021-11-19 22:53:46
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 138 ms / 2,000 ms
コード長 403 bytes
コンパイル時間 1,361 ms
コンパイル使用メモリ 87,020 KB
実行使用メモリ 104,408 KB
最終ジャッジ日時 2023-08-30 09:51:28
合計ジャッジ時間 6,644 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 74 ms
71,504 KB
testcase_01 AC 76 ms
71,200 KB
testcase_02 AC 73 ms
71,260 KB
testcase_03 AC 74 ms
71,248 KB
testcase_04 AC 75 ms
71,580 KB
testcase_05 AC 75 ms
71,064 KB
testcase_06 AC 73 ms
71,328 KB
testcase_07 AC 74 ms
71,316 KB
testcase_08 AC 115 ms
99,176 KB
testcase_09 AC 114 ms
98,352 KB
testcase_10 AC 105 ms
93,488 KB
testcase_11 AC 128 ms
99,748 KB
testcase_12 AC 104 ms
93,344 KB
testcase_13 AC 128 ms
99,600 KB
testcase_14 AC 112 ms
96,136 KB
testcase_15 AC 114 ms
98,464 KB
testcase_16 AC 115 ms
101,628 KB
testcase_17 AC 107 ms
96,288 KB
testcase_18 AC 127 ms
99,716 KB
testcase_19 AC 108 ms
95,752 KB
testcase_20 AC 134 ms
99,916 KB
testcase_21 AC 113 ms
98,840 KB
testcase_22 AC 134 ms
100,180 KB
testcase_23 AC 122 ms
104,408 KB
testcase_24 AC 137 ms
100,608 KB
testcase_25 AC 137 ms
100,416 KB
testcase_26 AC 138 ms
100,724 KB
testcase_27 AC 137 ms
100,600 KB
testcase_28 AC 131 ms
100,612 KB
testcase_29 AC 131 ms
100,560 KB
testcase_30 AC 130 ms
100,532 KB
testcase_31 AC 133 ms
100,628 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