結果

問題 No.1239 Multiplication -2
ユーザー marroncastlemarroncastle
提出日時 2020-09-26 02:41:38
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 331 ms / 2,000 ms
コード長 392 bytes
コンパイル時間 382 ms
コンパイル使用メモリ 86,988 KB
実行使用メモリ 105,420 KB
最終ジャッジ日時 2023-09-10 20:09:10
合計ジャッジ時間 8,584 ms
ジャッジサーバーID
(参考情報)
judge11 / judge14
このコードへのチャレンジ
(要ログイン)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 76 ms
71,264 KB
testcase_01 AC 73 ms
71,260 KB
testcase_02 AC 73 ms
71,228 KB
testcase_03 AC 132 ms
76,620 KB
testcase_04 AC 91 ms
76,692 KB
testcase_05 AC 88 ms
76,820 KB
testcase_06 AC 83 ms
76,328 KB
testcase_07 AC 86 ms
76,432 KB
testcase_08 AC 74 ms
71,428 KB
testcase_09 AC 73 ms
71,300 KB
testcase_10 AC 73 ms
71,156 KB
testcase_11 AC 74 ms
71,424 KB
testcase_12 AC 73 ms
71,432 KB
testcase_13 AC 73 ms
71,324 KB
testcase_14 AC 71 ms
70,956 KB
testcase_15 AC 152 ms
83,932 KB
testcase_16 AC 203 ms
91,372 KB
testcase_17 AC 316 ms
104,896 KB
testcase_18 AC 320 ms
105,080 KB
testcase_19 AC 309 ms
104,956 KB
testcase_20 AC 331 ms
105,420 KB
testcase_21 AC 297 ms
104,900 KB
testcase_22 AC 293 ms
104,760 KB
testcase_23 AC 235 ms
96,408 KB
testcase_24 AC 230 ms
95,900 KB
testcase_25 AC 203 ms
91,384 KB
testcase_26 AC 215 ms
93,828 KB
testcase_27 AC 142 ms
82,928 KB
testcase_28 AC 286 ms
101,816 KB
testcase_29 AC 294 ms
102,208 KB
testcase_30 AC 171 ms
86,480 KB
testcase_31 AC 218 ms
93,540 KB
testcase_32 AC 313 ms
105,232 KB
testcase_33 AC 240 ms
96,348 KB
testcase_34 AC 228 ms
93,672 KB
testcase_35 AC 153 ms
84,172 KB
testcase_36 AC 146 ms
83,100 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
  new_dp[1] = pow(2,i,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