题面有误
查看原帖
题面有误
727008
lwx20211103楼主2023/1/11 19:36

Different Arrays

题面翻译

给你一个有 nn 个元素的序列,你需要进行 n2n-2 次操作。

对于第 ii 次操作,你可以选择让 aiai+1a_i-a_{i+1}ai+2+ai+1ai+1a_{i+2}+\red{a{i + 1}}\green{a_{i+1}} 或者可以选择让 ai+ai+1a_i+a_{i+1}ai+2ai+1a_{i+2}-a_{i+1} 绿色是对的,红色是错的

问最后能产生多少个不同的序列。

题目描述

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

样例输入 #1

4
1 1 1 1

样例输出 #1

3

样例 #2

样例输入 #2

5
1 2 3 5 0

样例输出 #2

7

@小粉兔

2023/1/11 19:36
加载中...