結果

問題 No.1751 Fortune Nim
ユーザー tamatotamato
提出日時 2021-11-19 22:14:41
言語 PyPy3
(7.3.15)
結果
WA  
実行時間 -
コード長 669 bytes
コンパイル時間 288 ms
コンパイル使用メモリ 87,696 KB
実行使用メモリ 103,320 KB
最終ジャッジ日時 2023-08-30 08:51:16
合計ジャッジ時間 5,430 ms
ジャッジサーバーID
(参考情報)
judge12 / judge11
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 68 ms
71,860 KB
testcase_01 AC 69 ms
71,628 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 67 ms
71,968 KB
testcase_06 AC 68 ms
71,924 KB
testcase_07 AC 69 ms
71,492 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 103 ms
100,564 KB
testcase_17 AC 95 ms
95,416 KB
testcase_18 AC 113 ms
98,464 KB
testcase_19 AC 95 ms
94,908 KB
testcase_20 AC 117 ms
99,752 KB
testcase_21 AC 99 ms
97,548 KB
testcase_22 AC 117 ms
99,988 KB
testcase_23 AC 108 ms
103,320 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 119 ms
100,344 KB
testcase_29 AC 119 ms
100,256 KB
testcase_30 AC 117 ms
100,104 KB
testcase_31 AC 121 ms
100,036 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:
            S -= g
            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