結果

問題 No.1239 Multiplication -2
ユーザー りあんりあん
提出日時 2020-09-03 22:26:43
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 675 ms / 2,000 ms
コード長 475 bytes
コンパイル時間 601 ms
コンパイル使用メモリ 10,904 KB
実行使用メモリ 21,304 KB
最終ジャッジ日時 2023-08-15 19:52:30
合計ジャッジ時間 12,160 ms
ジャッジサーバーID
(参考情報)
judge14 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,752 KB
testcase_01 AC 16 ms
7,816 KB
testcase_02 AC 16 ms
7,876 KB
testcase_03 AC 21 ms
7,808 KB
testcase_04 AC 21 ms
7,840 KB
testcase_05 AC 22 ms
7,852 KB
testcase_06 AC 17 ms
7,804 KB
testcase_07 AC 18 ms
7,928 KB
testcase_08 AC 15 ms
7,736 KB
testcase_09 AC 15 ms
7,804 KB
testcase_10 AC 15 ms
7,880 KB
testcase_11 AC 15 ms
7,804 KB
testcase_12 AC 16 ms
7,756 KB
testcase_13 AC 15 ms
7,804 KB
testcase_14 AC 15 ms
7,852 KB
testcase_15 AC 214 ms
10,748 KB
testcase_16 AC 349 ms
12,568 KB
testcase_17 AC 632 ms
12,164 KB
testcase_18 AC 641 ms
12,104 KB
testcase_19 AC 646 ms
13,092 KB
testcase_20 AC 675 ms
21,304 KB
testcase_21 AC 607 ms
11,456 KB
testcase_22 AC 577 ms
11,456 KB
testcase_23 AC 452 ms
19,524 KB
testcase_24 AC 436 ms
17,520 KB
testcase_25 AC 387 ms
10,184 KB
testcase_26 AC 360 ms
18,168 KB
testcase_27 AC 179 ms
10,680 KB
testcase_28 AC 546 ms
16,444 KB
testcase_29 AC 597 ms
17,284 KB
testcase_30 AC 262 ms
11,988 KB
testcase_31 AC 392 ms
13,728 KB
testcase_32 AC 625 ms
17,620 KB
testcase_33 AC 456 ms
14,568 KB
testcase_34 AC 423 ms
14,052 KB
testcase_35 AC 212 ms
11,248 KB
testcase_36 AC 194 ms
10,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353
inv = (mod + 1) // 2

n = int(input())
a = list(map(int, input().split()))
dp = [0] * 5
dp[3] = 1
p = 1
pp = pow(2, n - 1, mod)
ans = 0
for i in a:
    nex = [0] * 5
    nex[3] = p
    p = p * 2 % mod
    ans = (ans + dp[0] * pp) % mod
    pp = pp * inv % mod
    for j in range(5):
        k = (j - 2) * i + 2
        if 0 <= k <= 4:
            nex[k] = (nex[k] + dp[j]) % mod
    dp = nex

ans = (ans + dp[0]) % mod
print(ans * pow(2, mod - n, mod) % mod)
0