当前你的浏览器版本过低,网站已在兼容模式下运行,兼容模式仅提供最小功能支持,网站样式可能显示不正常。
请尽快升级浏览器以体验网站在线编辑、在线运行等功能。

建议使用的浏览器:

谷歌Chrome 火狐Firefox Opera浏览器 微软Edge浏览器 QQ浏览器 360浏览器 傲游浏览器

6827:Road To The 3rd Building

题目描述
Because of the thriller adventure game The 3rd Building, there are fewer and fewer students who would like to go to the 3rd Building. So few students are working in the studio in the 3rd Building. Students are even more reluctant to go to the 3rd Building for experiments, which are also annoying.

Kanade takes responsibility to improve this status. She thinks it a good idea to decorate the ginkgo trees along the road to the 3rd Building, making them cute. There are $n$ ginkgo trees that are planted along the road, numbered with $1\ldots n$. Each tree has a cute value. The cute value of tree $i$ is $s_i$.

Kanade defines a plan as an ordered pair $(i,j)$, here $1\le i\le j\le n$. It means a student will appear at the position of the tree $i$ magically, walk along the road, and finally stop walking at the position of the tree $j$. The cute level of a plan is the average of the cute value of the trees visited. Formally, the cute level of plan $(i,j)$ is $\frac{1}{j-i+1}\sum_{k=i}^j s_k$.

Kanade wants to know the mathematical expectation of the cute level if a student will take a plan among all these plans in a uniformly random way. But she is busy with learning Computer Networking, would you help her?
输入解释
The first line of the input contains an integer $T$ — the number of testcases. You should process these testcases independently.

The first line of each testcase contains an integer $n$ — the number of ginkgo trees.

The second line of each testcase contains $n$ integers $s_i$ — the cute value of each ginkgo tree, space-separated.

$1\le T\le 20,1\le n\le 2\times 10^5,1\le s_i\le 10^9$

It is guaranteed that $\sum n\le 10^6$.
输出解释
For each testcase, output the answer in the fraction form modulo $10^9+7$ in one line. That is, if the answer is $\frac{P}{Q}$, you should output $P\cdot Q^{-1}\bmod (10^9+7)$, where $Q^{-1}$ denotes the multiplicative inverse of $Q$ modulo $10^9+7$.
输入样例
3
3
1 3 2
6
1 1 4 5 1 4
9
7325 516 56940 120670 16272 15007 337527 333184 742294
输出样例
83333336
188888893
303405448

提示
 The answer to the first testcase is 25/12. 
来自杭电HDUOJ的附加信息
Recommend IceyWang

该题目是Virtual Judge题目,来自 杭电HDUOJ

源链接: HDU-6827

最后修改于 2020-10-25T23:34:44+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000/1000MS(Java/Others) 524288/262144K(Java/Others)