#abc234g. G - Divide a Sequence
G - Divide a Sequence
Score : points
问题描述
给定一个包含 个数的序列 。
有 种方式将 划分成非空的 连续 子序列 。对于每一种划分方式,计算以下值,并将这些值按照模 的规则求和后输出结果。
这里,对于子序列 , 和 分别定义为 中元素的最大值和最小值。
以上为通义千问 qwen-max 翻译,仅供参考。
Problem Statement
Given is a sequence of numbers.
There are ways to divide into non-empty contiguous subsequences . Find the value below for each of those ways, and print the sum, modulo , of those values.
Here, for a sequence , and are defined to be the maximum and minimum values of an element of , respectively.
Constraints
- All values in input are integers.
Input
Input is given from Standard Input in the following format:
Output
Print the sum, modulo , of the values found.
Sample Input 1
3
1 2 3
Sample Output 1
2
There are ways to divide into non-empty contiguous subsequences, as follows.
- , ,
- ,
- ,
for these divisions are , , , , respectively. The sum of them, , should be printed.
Sample Input 2
4
1 10 1 10
Sample Output 2
90
Sample Input 3
10
699498050 759726383 769395239 707559733 72435093 537050110 880264078 699299140 418322627 134917794
Sample Output 3
877646588
Be sure to print the sum modulo .
update @ 2024/3/10 10:10:50
相关
在以下作业中: