結果

問題 No.1239 Multiplication -2
ユーザー りあんりあん
提出日時 2020-09-03 22:20:53
言語 Python3
(3.12.2 + numpy 1.26.4 + scipy 1.12.0)
結果
AC  
実行時間 706 ms / 2,000 ms
コード長 505 bytes
コンパイル時間 219 ms
コンパイル使用メモリ 10,856 KB
実行使用メモリ 21,268 KB
最終ジャッジ日時 2023-08-15 19:45:28
合計ジャッジ時間 13,190 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 16 ms
7,748 KB
testcase_01 AC 15 ms
7,824 KB
testcase_02 AC 15 ms
7,840 KB
testcase_03 AC 21 ms
7,800 KB
testcase_04 AC 22 ms
7,760 KB
testcase_05 AC 23 ms
7,816 KB
testcase_06 AC 18 ms
7,764 KB
testcase_07 AC 17 ms
7,820 KB
testcase_08 AC 16 ms
7,924 KB
testcase_09 AC 16 ms
7,860 KB
testcase_10 AC 16 ms
7,784 KB
testcase_11 AC 15 ms
7,860 KB
testcase_12 AC 16 ms
7,768 KB
testcase_13 AC 15 ms
7,920 KB
testcase_14 AC 16 ms
7,816 KB
testcase_15 AC 233 ms
10,652 KB
testcase_16 AC 370 ms
12,452 KB
testcase_17 AC 670 ms
11,968 KB
testcase_18 AC 690 ms
12,004 KB
testcase_19 AC 677 ms
13,072 KB
testcase_20 AC 697 ms
21,268 KB
testcase_21 AC 666 ms
11,576 KB
testcase_22 AC 632 ms
11,436 KB
testcase_23 AC 497 ms
19,364 KB
testcase_24 AC 493 ms
17,576 KB
testcase_25 AC 388 ms
10,336 KB
testcase_26 AC 454 ms
18,044 KB
testcase_27 AC 195 ms
10,712 KB
testcase_28 AC 613 ms
16,384 KB
testcase_29 AC 674 ms
17,312 KB
testcase_30 AC 292 ms
12,052 KB
testcase_31 AC 430 ms
13,688 KB
testcase_32 AC 706 ms
17,596 KB
testcase_33 AC 508 ms
14,500 KB
testcase_34 AC 471 ms
14,128 KB
testcase_35 AC 235 ms
11,204 KB
testcase_36 AC 209 ms
11,000 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 range(n):
    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) * a[i] + 2
        if not (0 <= k <= 4):
            k = 2
        nex[k] = (nex[k] + dp[j]) % mod
    dp = nex

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