#P2428. 均分数据

均分数据

题目描述

已知N个正整数:A1A2、……、An 。今要将它们分成M组,使得各组数据的数值和最平均,即各组的均方差最小。均方差公式如下:

,

mso-hansi-font-family:"Times New Roman"">其中

<span style="font-family:

宋体">σ</span><span style="font-family:宋体;mso-ascii-font-family:"Times New Roman";

mso-hansi-font-family:"Times New Roman"">为均方差,</span><span style="font-family:宋体;mso-ascii-font-family:

"Times New Roman";mso-hansi-font-family:"Times New Roman"">是各组数据和的平均值,</span>xi<span style="font-family:宋体;mso-ascii-font-family:

"Times New Roman";mso-hansi-font-family:"Times New Roman"">为第</span>i<span style="font-family:宋体;mso-ascii-font-family:"Times New Roman";

mso-hansi-font-family:"Times New Roman"">组数据的数值和。</span>

</p>

 

输入格式

第一行是两个整数,表示N,M的值(N是整数个数,M是要分成的组数)
第二行有N个整数,表示A1、A2、……、An。整数的范围是1--50。
(同一行的整数间用空格分开)

输出格式

<span style="font-family:宋体;

mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:"Times New Roman"">这一行只包含一个数,表示最小均方差的值</span>(<span style="font-family:宋体;mso-ascii-font-family:"Times New Roman";

mso-hansi-font-family:"Times New Roman"">保留小数点后两位数字</span>)<span style="font-family:宋体;mso-ascii-font-family:"Times New Roman";mso-hansi-font-family:

"Times New Roman"">。</span>

</p>

6 3
1 2 3 4 5 6
0.00

数据范围与约定

对于全部的数据,保证有K<=N <= 20,2<=K<=6