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

建议使用的浏览器:

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

3638:Moogle

题目描述

You got the original idea of making map software, called Moogle Maps, for the new cool Maple mPhone. It will even be capable of indicating the location of a house address like "Main Street 13". However, since the mPhone has limited storage capacity, you need to reduce the data amount. You don't want to store the exact location of every single house number. Instead only a subset of the house numbers will be stored exactly, and the others will be linearly interpolated. So you want to select house numbers that will minimise the average interpolation error, given how many house locations you have capacity to store. We view the street as a straight line, and you will always store the first and the last house location.

Given that you've stored the locations xi and xj for the houses with numbers i and j respectively, but no other house in between, the interpolated value for a house with number k with i < k < j is __poj_jax_start__x_i + (x_j - x_i) \times \frac{k-i}{j-i}__poj_jax_end__x_i + (x_j - x_i) \times \frac{k-i}{j-i}.

输入解释

The first line of input gives a single integer, 1 ≤ t ≤ 50, the number of test cases. For each test case, there are two lines. The first contains 2 ≤ h ≤ 200 and 2 ≤ ch, where h is the number of houses in the street and c is the number of house locations that can be stored. The second contains h integers in increasing order giving the location of the h houses. Each location is in the interval [0, 1000000].

输出解释

For each test case, output the average interpolation error over all the h houses for the optimal selection of c house locations to store. The output should be given with four decimal places, but we will accept inaccuracies of up to ±0.001.

输入样例
2
4 3
0 9 20 40
10 4
0 10 19 30 40 90 140 190 202 210
输出样例
0.2500
0.3000

该题目是Virtual Judge题目,来自 北京大学POJ

题目来源 Nordic 2007

源链接: POJ-3638

最后修改于 2020-10-29T07:06:36+00:00 由爬虫自动更新

共提交 0

通过率 --%
时间上限 内存上限
2000 65536