#abc290e. E - Make it Palindrome
E - Make it Palindrome
Score : points
问题描述
对于一个序列 ,令 (将 改造为回文串所需的最少元素修改次数)。
给定长度为 的序列 ,求 中所有 连续 子数组的 值之和。
这里,长度为 的序列 被称为回文串,当且仅当对于所有 , 的第 个元素与第 个元素相等。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
For a sequence , let (the minimum number of elements one must modify to make a palindrome).
Given a sequence of length , find the sum of over all contiguous subarrays of .
Here, a sequence of length is said to be a palindrome if and only if the -th and the -th elements of are equal for all .
Constraints
- All values in the input are integers.
Input
The input is given from Standard Input in the following format:
Output
Print the answer as an integer.
Sample Input 1
5
5 2 1 2 2
Sample Output 1
9
Therefore, the sought answer is .
update @ 2024/3/10 12:07:15