結果

問題 No.1239 Multiplication -2
ユーザー googol_S0googol_S0
提出日時 2020-09-25 22:24:03
言語 PyPy3
(7.3.15)
結果
AC  
実行時間 365 ms / 2,000 ms
コード長 382 bytes
コンパイル時間 399 ms
コンパイル使用メモリ 87,044 KB
実行使用メモリ 110,436 KB
最終ジャッジ日時 2023-09-10 15:39:28
合計ジャッジ時間 9,486 ms
ジャッジサーバーID
(参考情報)
judge15 / judge13
このコードへのチャレンジ(β)

テストケース

テストケース表示
入力 結果 実行時間
実行使用メモリ
testcase_00 AC 73 ms
71,340 KB
testcase_01 AC 75 ms
71,404 KB
testcase_02 AC 72 ms
71,428 KB
testcase_03 AC 100 ms
76,656 KB
testcase_04 AC 97 ms
76,732 KB
testcase_05 AC 97 ms
76,940 KB
testcase_06 AC 84 ms
76,340 KB
testcase_07 AC 86 ms
76,392 KB
testcase_08 AC 75 ms
71,044 KB
testcase_09 AC 74 ms
71,524 KB
testcase_10 AC 72 ms
71,124 KB
testcase_11 AC 73 ms
71,276 KB
testcase_12 AC 73 ms
71,164 KB
testcase_13 AC 72 ms
71,276 KB
testcase_14 AC 73 ms
71,280 KB
testcase_15 AC 179 ms
91,424 KB
testcase_16 AC 236 ms
99,628 KB
testcase_17 AC 347 ms
110,344 KB
testcase_18 AC 347 ms
110,044 KB
testcase_19 AC 361 ms
110,436 KB
testcase_20 AC 358 ms
110,152 KB
testcase_21 AC 339 ms
110,180 KB
testcase_22 AC 333 ms
110,268 KB
testcase_23 AC 272 ms
102,612 KB
testcase_24 AC 266 ms
103,004 KB
testcase_25 AC 233 ms
99,328 KB
testcase_26 AC 248 ms
101,004 KB
testcase_27 AC 161 ms
89,108 KB
testcase_28 AC 324 ms
107,388 KB
testcase_29 AC 338 ms
107,272 KB
testcase_30 AC 198 ms
95,276 KB
testcase_31 AC 250 ms
101,292 KB
testcase_32 AC 365 ms
110,340 KB
testcase_33 AC 277 ms
103,040 KB
testcase_34 AC 262 ms
101,100 KB
testcase_35 AC 176 ms
91,468 KB
testcase_36 AC 168 ms
89,872 KB
権限があれば一括ダウンロードができます

ソースコード

diff #

N=int(input())
A=list(map(int,input().split()))
DP=[[0]*5 for i in range(N+1)]
mod=998244353
DP[0][1]=1
for i in range(N):
  DP[i+1][1]=pow(2,i,mod)
for i in range(N):
  for j in range(-2,3):
    if abs(A[i]*j)>3:
      continue
    DP[i+1][j*A[i]]=(DP[i+1][j*A[i]]+DP[i][j])%mod
print((sum(DP[i][-2]*pow(2,N-i-1,mod) for i in range(N))+DP[N][-2])*pow(pow(2,mod-2,mod),N-1,mod)%mod)
0