102305: [AtCoder]ABC230 F - Predilection

Memory Limit:256 MB Time Limit:2 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Score : $500$ points

Problem Statement

Given is a sequence $A$ of length $N$. You can do this operation any number of times: when the length of the sequence is at least $2$, choose two adjacent values, delete them, and insert their sum where they were. How many sequences can result from zero or more operations? Find the count modulo $998244353$.

Constraints

  • $1 \leq N \leq 2\times 10^5$
  • $|A_i| \leq 10^9$
  • All values in input are integers.

Input

Input is given from Standard Input in the following format:

$N$
$A_1$ $A_2$ $\cdots$ $A_N$

Output

Print the answer.


Sample Input 1

3
1 -1 1

Sample Output 1

4

The following four sequences can result from zero or more operations.

  • ${1,-1,1}$
  • ${1,0}$
  • ${0,1}$
  • ${1}$

Sample Input 2

10
377914575 -275478149 0 -444175904 719654053 -254224494 -123690081 377914575 -254224494 -21253655

Sample Output 2

321

Input

题意翻译

[芷萱姐姐](https://www.luogu.com.cn/user/208653)有一个长度为 $N$ 的数列 $A_i$。 你可以进行若干次,最多 $N-1$ 次操作,选择相邻的两个数,删去他们,并在原位置放上他们两个的和。 现在你需要求出可能产生的序列个数。 + $1 \le N \le 2 \times 10^5$ + $|A_i| \le 10^9$ Translated by [Tx_Lcy](https://www.luogu.com.cn/user/253608)

Output

得分:500分

问题描述

给定长度为 $N$ 的序列 $A$。 你可以进行任意多次操作:当序列的长度至少为 $2$ 时,选择两个相邻的值,删除它们,并在原来的位置插入它们的和。 经过零次或多次操作后,可以得到多少种不同的序列?求这个数对 $998244353$ 取模的结果。

限制条件

  • $1 \leq N \leq 2\times 10^5$
  • $|A_i| \leq 10^9$
  • 输入中的所有值都是整数。

输入

从标准输入以以下格式获取输入:

$N$
$A_1$ $A_2$ $\cdots$ $A_N$

输出

打印答案。


样例输入 1

3
1 -1 1

样例输出 1

4

经过零次或多次操作后,可以得到以下四种不同的序列。

  • ${1,-1,1}$
  • ${1,0}$
  • ${0,1}$
  • ${1}$

样例输入 2

10
377914575 -275478149 0 -444175904 719654053 -254224494 -123690081 377914575 -254224494 -21253655

样例输出 2

321

加入题单

算法标签: