304235: CF808B. Average Sleep Time

Memory Limit:256 MB Time Limit:1 S
Judge Style:Text Compare Creator:
Submit:0 Solved:0

Description

Average Sleep Time

题意翻译

现在给你 $n$ 个数字,让你选出连续的 $k$ 个数字。显然,这样的方案一共有 $n-k+1$ 种,我们定义每一种方案的权值是该方案选出的数字的和。现在请问,所有方案权值的平均数是多少?(建议精确到小数点后9位)

题目描述

It's been almost a week since Polycarp couldn't get rid of insomnia. And as you may already know, one week in Berland lasts $ k $ days! When Polycarp went to a doctor with his problem, the doctor asked him about his sleeping schedule (more specifically, the average amount of hours of sleep per week). Luckily, Polycarp kept records of sleep times for the last $ n $ days. So now he has a sequence $ a_{1},a_{2},...,a_{n} $ , where $ a_{i} $ is the sleep time on the $ i $ -th day. The number of records is so large that Polycarp is unable to calculate the average value by himself. Thus he is asking you to help him with the calculations. To get the average Polycarp is going to consider $ k $ consecutive days as a week. So there will be $ n-k+1 $ weeks to take into consideration. For example, if $ k=2 $ , $ n=3 $ and $ a=[3,4,7] $ , then the result is ![](https://cdn.luogu.com.cn/upload/vjudge_pic/CF808B/86ab5f462dc3fdaf9fb78d24cfe814007844dab2.png). You should write a program which will calculate average sleep times of Polycarp over all weeks.

输入输出格式

输入格式


The first line contains two integer numbers $ n $ and $ k $ ( $ 1<=k<=n<=2·10^{5} $ ). The second line contains $ n $ integer numbers $ a_{1},a_{2},...,a_{n} $ ( $ 1<=a_{i}<=10^{5} $ ).

输出格式


Output average sleeping time over all weeks. The answer is considered to be correct if its absolute or relative error does not exceed $ 10^{-6} $ . In particular, it is enough to output real number with at least 6 digits after the decimal point.

输入输出样例

输入样例 #1

3 2
3 4 7

输出样例 #1

9.0000000000

输入样例 #2

1 1
10

输出样例 #2

10.0000000000

输入样例 #3

8 2
1 2 4 100000 123 456 789 1

输出样例 #3

28964.2857142857

说明

In the third example there are $ n-k+1=7 $ weeks, so the answer is sums of all weeks divided by 7.

Input

题意翻译

现在给你 $n$ 个数字,让你选出连续的 $k$ 个数字。显然,这样的方案一共有 $n-k+1$ 种,我们定义每一种方案的权值是该方案选出的数字的和。现在请问,所有方案权值的平均数是多少?(建议精确到小数点后9位)

加入题单

算法标签: