CF1783D.Different Arrays

普及/提高-

通过率:0%

AC君温馨提醒

该题目为【codeforces】题库的题目,您提交的代码将被提交至codeforces进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。

题目描述

You are given an array aa consisting of nn integers.

You have to perform the sequence of n2n-2 operations on this array:

  • during the first operation, you either add a2a_2 to a1a_1 and subtract a2a_2 from a3a_3 , or add a2a_2 to a3a_3 and subtract a2a_2 from a1a_1 ;
  • during the second operation, you either add a3a_3 to a2a_2 and subtract a3a_3 from a4a_4 , or add a3a_3 to a4a_4 and subtract a3a_3 from a2a_2 ;
  • ...
  • during the last operation, you either add an1a_{n-1} to an2a_{n-2} and subtract an1a_{n-1} from ana_n , or add an1a_{n-1} to ana_n and subtract an1a_{n-1} from an2a_{n-2} .

So, during the ii -th operation, you add the value of ai+1a_{i+1} to one of its neighbors, and subtract it from the other neighbor.

For example, if you have the array [1,2,3,4,5][1, 2, 3, 4, 5] , one of the possible sequences of operations is:

  • subtract 22 from a3a_3 and add it to a1a_1 , so the array becomes [3,2,1,4,5][3, 2, 1, 4, 5] ;
  • subtract 11 from a2a_2 and add it to a4a_4 , so the array becomes [3,1,1,5,5][3, 1, 1, 5, 5] ;
  • subtract 55 from a3a_3 and add it to a5a_5 , so the array becomes [3,1,4,5,10][3, 1, -4, 5, 10] .

So, the resulting array is [3,1,4,5,10][3, 1, -4, 5, 10] .

An array is reachable if it can be obtained by performing the aforementioned sequence of operations on aa . You have to calculate the number of reachable arrays, and print it modulo 998244353998244353 .

输入格式

The first line contains one integer nn ( 3n3003 \le n \le 300 ).

The second line contains nn integers a1,a2,,ana_1, a_2, \dots, a_n ( 0ai3000 \le a_i \le 300 ).

输出格式

Print one integer — the number of reachable arrays. Since the answer can be very large, print its remainder modulo 998244353998244353 .

输入输出样例

  • 输入#1

    4
    1 1 1 1

    输出#1

    3
  • 输入#2

    5
    1 2 3 5 0

    输出#2

    7
首页