QOJ.ac

QOJ

時間限制: 1 s 記憶體限制: 512 MB 總分: 100 可 Hack ✓

#7374. 迷途知返

统计

問題文

$n+1$ 個の頂点を持つ鎖状のグラフがあり、一方の端からもう一方の端まで順に $0, 1, \dots, n$ と番号が付けられている。頂点 $0$ から出発し、再び頂点 $0$ に戻るオイラー回路のうち、辺 $(i-1, i)$ を通過する回数がちょうど $2d_i$ 回であるようなものの個数を求めたい。答えを $998244353$ で割った余りを出力せよ。

入力

1 行目に正整数 $n$ が与えられる。

続く 1 行に $n$ 個の正整数が与えられる。$i$ 番目の値は $d_i$ である。

出力

方案の数を $998244353$ で割った余りを整数で出力せよ。

入出力例

入力 1

2
2 1

出力 1

2

説明 1

一歩進んだ後、そのまま進み続けるか引き返すかを選択できる。それ以降は唯一の選択肢しかない。

入力 2

4
200 30 8 11

出力 2

812059605

制約

すべてのデータにおいて、$1 \le n, d_i \le 10^5$ を満たす。

Discussions

About Discussions

The discussion section is only for posting: General Discussions (problem-solving strategies, alternative approaches), and Off-topic conversations.

This is NOT for reporting issues! If you want to report bugs or errors, please use the Issues section below.

Open Discussions 0
No discussions in this category.

Issues

About Issues

If you find any issues with the problem (statement, scoring, time/memory limits, test cases, etc.), you may submit an issue here. A problem moderator will review your issue.

Guidelines:

  1. This is not a place to publish discussions, editorials, or requests to debug your code. Issues are only visible to you and problem moderators.
  2. Do not submit duplicated issues.
  3. Issues must be filed in English or Chinese only.
Active Issues 0
No issues in this category.
Closed/Resolved Issues 0
No issues in this category.