310108: CF1783D. Different Arrays

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

Description

Different Arrays

题意翻译

给你一个有 $n$ 个元素的序列,你需要进行 $n-2$ 次操作。 对于第 $i$ 次操作,你可以选择让 $a_i-a_{i+1}$ 且 $a_{i+2}+a_{i+1}$ 或者可以选择让 $a_i+a_{i+1}$ 且 $a_{i+2}-a_{i+1}$ 问最后能产生多少个不同的序列。

题目描述

You are given an array $ a $ consisting of $ n $ integers. You have to perform the sequence of $ n-2 $ operations on this array: - during the first operation, you either add $ a_2 $ to $ a_1 $ and subtract $ a_2 $ from $ a_3 $ , or add $ a_2 $ to $ a_3 $ and subtract $ a_2 $ from $ a_1 $ ; - during the second operation, you either add $ a_3 $ to $ a_2 $ and subtract $ a_3 $ from $ a_4 $ , or add $ a_3 $ to $ a_4 $ and subtract $ a_3 $ from $ a_2 $ ; - ... - during the last operation, you either add $ a_{n-1} $ to $ a_{n-2} $ and subtract $ a_{n-1} $ from $ a_n $ , or add $ a_{n-1} $ to $ a_n $ and subtract $ a_{n-1} $ from $ a_{n-2} $ . So, during the $ i $ -th operation, you add the value of $ a_{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] $ , one of the possible sequences of operations is: - subtract $ 2 $ from $ a_3 $ and add it to $ a_1 $ , so the array becomes $ [3, 2, 1, 4, 5] $ ; - subtract $ 1 $ from $ a_2 $ and add it to $ a_4 $ , so the array becomes $ [3, 1, 1, 5, 5] $ ; - subtract $ 5 $ from $ a_3 $ and add it to $ a_5 $ , so the array becomes $ [3, 1, -4, 5, 10] $ . So, the resulting array is $ [3, 1, -4, 5, 10] $ . An array is reachable if it can be obtained by performing the aforementioned sequence of operations on $ a $ . You have to calculate the number of reachable arrays, and print it modulo $ 998244353 $ .

输入输出格式

输入格式


The first line contains one integer $ n $ ( $ 3 \le n \le 300 $ ). The second line contains $ n $ integers $ a_1, a_2, \dots, a_n $ ( $ 0 \le a_i \le 300 $ ).

输出格式


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

输入输出样例

输入样例 #1

4
1 1 1 1

输出样例 #1

3

输入样例 #2

5
1 2 3 5 0

输出样例 #2

7

Input

题意翻译

给你一个有 $n$ 个元素的序列,你需要进行 $n-2$ 次操作。 对于第 $i$ 次操作,你可以选择让 $a_i-a_{i+1}$ 且 $a_{i+2}+a_{i+1}$ 或者可以选择让 $a_i+a_{i+1}$ 且 $a_{i+2}-a_{i+1}$ 问最后能产生多少个不同的序列。

Output

题目大意:
给你一个包含 $ n $ 个整数的序列 $ a $。你需要对这个序列进行 $ n-2 $ 次操作,每次操作可以选择将 $ a_{i+1} $ 加到 $ a_i $ 上同时从 $ a_{i+2} $ 中减去 $ a_{i+1} $,或者将 $ a_{i+1} $ 加到 $ a_{i+2} $ 上同时从 $ a_i $ 中减去 $ a_{i+1} $。问最后能产生多少个不同的序列。

输入输出数据格式:
输入格式:
- 第一行包含一个整数 $ n $($ 3 \le n \le 300 $)。
- 第二行包含 $ n $ 个整数 $ a_1, a_2, \dots, a_n $($ 0 \le a_i \le 300 $)。

输出格式:
- 输出一个整数,表示可到达的不同序列的数量。由于答案可能非常大,输出其对 $ 998244353 $ 取模后的结果。

输入输出样例:
输入样例 #1:
```
4
1 1 1 1
```
输出样例 #1:
```
3
```
输入样例 #2:
```
5
1 2 3 5 0
```
输出样例 #2:
```
7
```题目大意: 给你一个包含 $ n $ 个整数的序列 $ a $。你需要对这个序列进行 $ n-2 $ 次操作,每次操作可以选择将 $ a_{i+1} $ 加到 $ a_i $ 上同时从 $ a_{i+2} $ 中减去 $ a_{i+1} $,或者将 $ a_{i+1} $ 加到 $ a_{i+2} $ 上同时从 $ a_i $ 中减去 $ a_{i+1} $。问最后能产生多少个不同的序列。 输入输出数据格式: 输入格式: - 第一行包含一个整数 $ n $($ 3 \le n \le 300 $)。 - 第二行包含 $ n $ 个整数 $ a_1, a_2, \dots, a_n $($ 0 \le a_i \le 300 $)。 输出格式: - 输出一个整数,表示可到达的不同序列的数量。由于答案可能非常大,输出其对 $ 998244353 $ 取模后的结果。 输入输出样例: 输入样例 #1: ``` 4 1 1 1 1 ``` 输出样例 #1: ``` 3 ``` 输入样例 #2: ``` 5 1 2 3 5 0 ``` 输出样例 #2: ``` 7 ```

加入题单

算法标签: