$$4.182$$

$$4.1820000000000003836930773104541003704071044921875$$

OK，说完背景，让我们再回到OJ的问题上来。

# 1104 Sum of Number Segments

## 题目

Given a sequence of positive numbers, a segment is defined to be a consecutive subsequence. For example, given the sequence { 0.1, 0.2, 0.3, 0.4 }, we have 10 segments: (0.1) (0.1, 0.2) (0.1, 0.2, 0.3) (0.1, 0.2, 0.3, 0.4) (0.2) (0.2, 0.3) (0.2, 0.3, 0.4) (0.3) (0.3, 0.4) and (0.4).

Now given a sequence, you are supposed to find the sum of all the numbers in all the segments. For the previous example, the sum of all the 10 segments is 0.1 + 0.3 + 0.6 + 1.0 + 0.2 + 0.5 + 0.9 + 0.3 + 0.7 + 0.4 = 5.0.

### Input Specification:

Each input file contains one test case. For each case, the first line gives a positive integer N, the size of the sequence which is no more than 105. The next line contains N positive numbers in the sequence, each no more than 1.0, separated by a space.

### Output Specification:

For each test case, print in one line the sum of all the numbers in all the segments, accurate up to 2 decimal places.

## 动态规划

$$A_{n}=A_{n+1}+(N-n+1)S_{n}$$

# 谁更精确？

Java提供了可以比较精确地进行数学计算的大数类BigDeciaml，于是，测试程序可以稍微改一下，使用Java跑出“精确答案”。

Java BigDecimal （我的方法） 82725496576006.158000 0
Java BigDecimal （标准答案） 82725496576006.158000 0
C++ （我的方法） 82725496576006.140625 0.017375
C++ （标准答案） 82725496576005.750000 0.408000

# 后记

2020.6.15 更新：经过反馈，PAT已经修改了该题数据

2020.6.16 再次更新：已AC，但我反馈的不是这个意思…

ε=ε=ε=(~￣▽￣)~