結果

問題 No.1751 Fortune Nim
ユーザー tamatotamato
提出日時 2021-11-19 22:22:16
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 792 bytes
コンパイル時間 316 ms
コンパイル使用メモリ 87,524 KB
実行使用メモリ 103,244 KB
最終ジャッジ日時 2023-08-30 09:03:53
合計ジャッジ時間 5,385 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,852 KB
testcase_01 AC 71 ms
71,716 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 70 ms
71,728 KB
testcase_06 AC 70 ms
71,872 KB
testcase_07 AC 71 ms
71,652 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 108 ms
100,308 KB
testcase_17 AC 99 ms
95,024 KB
testcase_18 AC 117 ms
98,576 KB
testcase_19 AC 100 ms
94,576 KB
testcase_20 AC 122 ms
99,852 KB
testcase_21 AC 104 ms
97,736 KB
testcase_22 AC 122 ms
99,972 KB
testcase_23 AC 111 ms
103,244 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 120 ms
100,148 KB
testcase_29 AC 122 ms
100,276 KB
testcase_30 AC 122 ms
100,396 KB
testcase_31 AC 121 ms
100,028 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    A = list(map(int, input().split()))

    if N == 1:
        print(665496236)
    else:
        S = sum(A)
        g = 0
        for a in A:
            g ^= a
        if g:
            ma = 0
            for a in A:
                if a >= a ^ g:
                    ma = max(ma, (a - (a ^ g)))
            S -= ma
            lower = pow(3, S, mod)
            upper = ((lower + 1) * pow(2, mod-2, mod))%mod
            print((upper * pow(lower, mod-2, mod))%mod)
        else:
            lower = pow(3, S, mod)
            upper = ((lower - 1) * pow(2, mod - 2, mod)) % mod
            print((upper * pow(lower, mod - 2, mod)) % mod)


if __name__ == '__main__':
    main()
0