結果

問題 No.1239 Multiplication -2
ユーザー marroncastlemarroncastle
提出日時 2020-09-26 02:30:25
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 329 ms / 2,000 ms
コード長 445 bytes
コンパイル時間 2,000 ms
コンパイル使用メモリ 86,600 KB
実行使用メモリ 105,456 KB
最終ジャッジ日時 2023-09-10 19:50:25
合計ジャッジ時間 9,152 ms
ジャッジサーバーID
(参考情報)
judge12 / judge13
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 72 ms
71,368 KB
testcase_01 AC 72 ms
71,092 KB
testcase_02 AC 72 ms
71,108 KB
testcase_03 AC 92 ms
76,788 KB
testcase_04 AC 88 ms
76,736 KB
testcase_05 AC 88 ms
76,832 KB
testcase_06 AC 82 ms
76,536 KB
testcase_07 AC 82 ms
76,504 KB
testcase_08 AC 70 ms
71,408 KB
testcase_09 AC 72 ms
71,252 KB
testcase_10 AC 71 ms
71,380 KB
testcase_11 AC 73 ms
71,412 KB
testcase_12 AC 71 ms
71,244 KB
testcase_13 AC 72 ms
71,084 KB
testcase_14 AC 72 ms
71,336 KB
testcase_15 AC 152 ms
84,108 KB
testcase_16 AC 200 ms
91,308 KB
testcase_17 AC 313 ms
104,880 KB
testcase_18 AC 318 ms
104,908 KB
testcase_19 AC 307 ms
105,092 KB
testcase_20 AC 329 ms
105,456 KB
testcase_21 AC 294 ms
104,888 KB
testcase_22 AC 289 ms
104,832 KB
testcase_23 AC 234 ms
96,160 KB
testcase_24 AC 226 ms
95,996 KB
testcase_25 AC 200 ms
91,284 KB
testcase_26 AC 211 ms
93,704 KB
testcase_27 AC 140 ms
82,724 KB
testcase_28 AC 277 ms
101,872 KB
testcase_29 AC 293 ms
101,992 KB
testcase_30 AC 170 ms
86,456 KB
testcase_31 AC 214 ms
93,500 KB
testcase_32 AC 310 ms
105,324 KB
testcase_33 AC 242 ms
95,900 KB
testcase_34 AC 225 ms
93,664 KB
testcase_35 AC 152 ms
84,220 KB
testcase_36 AC 143 ms
83,152 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

mod = 998244353
N = int(input())
A = list(map(int, input().split()))
ans = 0
dp = [0]*5
dp[1] = 1
for i in range(N):
  new_dp = [0]*5
  if i<N-1:
    new_dp[1] = pow(2,i,mod)
  else:
    new_dp[1] = pow(2,i-1,mod)
  for j in range(-2,3):
    if abs(j*A[i])<=2:
      new_dp[j*A[i]] += dp[j]
  dp = new_dp
  if i==N-1:
    ans += dp[-2]
  else:
    ans += dp[-2]*pow(2,N-2-i,mod)
  ans %= mod
ans *= pow(pow(2,N-1,mod),mod-2,mod)
print(ans%mod)

0