結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,904 KB
testcase_01 AC 72 ms
71,572 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 73 ms
71,884 KB
testcase_06 AC 72 ms
71,800 KB
testcase_07 AC 72 ms
72,108 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
100,328 KB
testcase_17 AC 99 ms
94,860 KB
testcase_18 AC 116 ms
98,560 KB
testcase_19 AC 99 ms
94,888 KB
testcase_20 AC 121 ms
99,868 KB
testcase_21 AC 103 ms
97,536 KB
testcase_22 AC 124 ms
100,112 KB
testcase_23 AC 112 ms
103,424 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 121 ms
100,000 KB
testcase_29 AC 121 ms
100,160 KB
testcase_30 AC 123 ms
100,368 KB
testcase_31 AC 122 ms
100,172 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:
            for a in A:
                if a >= a ^ g:
                    S -= (a - (a ^ g))
                    break
            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