結果

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

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 70 ms
71,540 KB
testcase_01 AC 71 ms
71,816 KB
testcase_02 WA -
testcase_03 WA -
testcase_04 WA -
testcase_05 AC 71 ms
71,816 KB
testcase_06 AC 71 ms
71,716 KB
testcase_07 AC 72 ms
71,772 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,124 KB
testcase_17 AC 99 ms
94,720 KB
testcase_18 AC 117 ms
98,364 KB
testcase_19 AC 98 ms
94,148 KB
testcase_20 AC 122 ms
99,424 KB
testcase_21 AC 104 ms
97,384 KB
testcase_22 AC 124 ms
99,484 KB
testcase_23 AC 113 ms
103,196 KB
testcase_24 WA -
testcase_25 WA -
testcase_26 WA -
testcase_27 WA -
testcase_28 AC 122 ms
100,032 KB
testcase_29 AC 121 ms
99,804 KB
testcase_30 AC 121 ms
99,668 KB
testcase_31 AC 122 ms
99,672 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)
        if S & 1:
            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