AT_abc468_e.Sum of Average
普及+/提高
通过率:0%
时间限制:2.00s
内存限制:1024MB
AC君温馨提醒
该题目为【atcoder】题库的题目,您提交的代码将被提交至atcoder进行远程评测,并由ACGO抓取测评结果后进行展示。由于远程测评的测评机由其他平台提供,我们无法保证该服务的稳定性,若提交后无反应,请等待一段时间后再进行重试。
题目描述
You are given a positive integer N and a length-N integer sequence A=(A1,A2,…,AN).
Define f(l,r) as the (arithmetic) mean of Al,Al+1,…,Ar.
Find 1≤l≤r≤N∑f(l,r), modulo 998244353.
Definition of a rational number modulo 998244353
Under the constraints of this problem, it can be proved that the rational number to be found is always an irreducible fraction QP such that Q≡0(mod998244353). Thus, there is a unique integer R such that R×Q≡P(mod998244353),0≤R<998244353. Output this R.
给定一个正整数 N 和一个长度为 N 的整数序列 A=(A1,A2,…,AN)。
定义 f(l,r) 为 Al,Al+1,…,Ar 的(算术)平均值。
求 1≤l≤r≤N∑f(l,r) 对 998244353 取模的结果。
有理数对 998244353 取模的定义
在本题的约束条件下,可以证明所求的有理数恒为一个既约分数 QP,且满足 Q≡0(mod998244353)。因此,存在唯一的整数 R 满足 R×Q≡P(mod998244353) 且 0≤R<998244353。请输出该 R。
输入格式
The input is given from Standard Input in the following format:
N
A1 A2 … AN
输入从标准输入中按以下格式给出:
N
A1 A2 … AN
输出格式
Output the answer.
输出答案。
输入输出样例
输入#1
2 2 3
输出#1
499122184
输入#2
6 1 2 3 4 5 6
输出#2
499122250
输入#3
9 3 1 4 1 5 9 2 6 5
输出#3
855638200
说明/提示
Sample 1 Explanation:
We have f(1,1)=2,f(1,2)=22+3=25,f(2,2)=3. Thus, 1≤l≤r≤N∑f(l,r)=2+25+3=215.
215 in modulo-998244353 expression is 499122184, so output 499122184.
Constraints
- 1≤N≤5×105
- 0≤Ai<998244353
- All input values are integers.
样例 1 解释:
我们有 f(1,1)=2,f(1,2)=22+3=25,f(2,2)=3。因此,1≤l≤r≤N∑f(l,r)=2+25+3=215。
215 在模 998244353 意义下的值为 499122184,故输出 499122184。
约束条件
- 1≤N≤5×105
- 0≤Ai<998244353
- 所有输入值均为整数。
输入解题思路,AI测评打分。不知道怎么写?