QOJ.ac

QOJ

Time Limit: 2 s Memory Limit: 512 MB Total points: 100

#4060. 多边形

الإحصائيات

给定一个正 $n$ 边形,除了这个正 $n$ 边形的 $n$ 个顶点,顺时针第 $i$ 条边上还有额外的 $a_i-1$ 个顶点等分这条线段,也就是说,第 $i$ 条线段被顶点分成了长度相等的 $a_i$ 段。

你可以在顶点之间连接一些线段,但是连接完线段之后,图中的任意两条新添加的线段只能在端点处有交,此外,新的线段也不应该与多边形的边有重合。

我们称添加了若干线段以后得到的图为一个三角剖分,当且仅当多边形内的每个面都是一个三角形,注意,三角形的边上可以有原来凸多边形边上的顶点。

给定这样一个凸多边形,其有多少种满足上述条件的三角剖分?你只需要计算方案数取模 $998\,244\,353$ 的答案就行。

输入格式

第一行输入一个整数 $n$,表示凸多边形的边数。

第二行输入 $n$ 个正整数,其中第 $i$ 个正整数为 $a_i$,含义如题目描述中所示。

输出格式

输出一行一个整数,表示满足题目要求的三角剖分的方案数取模 $998\,244\,353$ 的结果。

样例数据

样例 1 输入

3
2 2 1

样例 1 输出

5

样例 1 解释

$5$ 种方案如图所示。

problem_4060_1.png

样例 2 输入

5
3 1 4 2 5

样例 2 输出

359895

样例 3 输入

8
4 2 1 8 3 7 3 1

样例 3 输出

577596154

子任务

对于 $10\%$ 的数据,保证 $\sum a_i \leq 300$。

对于 $50\%$ 的数据,保证 $\sum a_i \leq 5\,000$。

对于 $100\%$ 的数据,保证 $n \geq 3$,$a_i \geq 1$,$\sum a_i \leq 5 \times 10^5$。

About Issues

We understand that our problem archive is not perfect. If you find any issues with the problem, including the statement, scoring configuration, time/memory limits, test cases, etc.

You may use this form to submit an issue regarding the problem. A problem moderator will review your issue and proceed it properly.

STOP! Before you submit an issue, please READ the following guidelines:

  1. This is not a place to publish a discussion, editorial, or requests to debug your code. Your issue will only be visible by you and problem moderators. Other users will not be able to view or reply your issues.
  2. Do not submit duplicated issues. If you have already submitted one, please wait for an moderator to review it. Submitting multiple issues will not speed up the review process and might cause your account to be banned.
  3. Issues must be filed in English or Chinese only.
  4. Be sure your issue is related to this problem. If you need to submit an issue regarding another problem, contest, category, etc., you should submit it to the corresponding page.

Active Issues 0

No issues in this category.

Closed/Resolved Issues 0

No issues in this category.