Necklace

TimeLimit:3000MS  MemoryLimit:524MB
64-bit integer IO format:%I64d
未提交 | 登录后收藏
Problem Description

Xzz is a child with severe procrastinations. The new semester begins, He still has a lot of homework to do. Now there are K friends help him finish his homework. Xzz has a necklace with n pearl. Now he want to Split into k parts, and send them to these k friends. Each friend will have a value representative how happy they are. And the value is equal the square of sum of the pearl in one part. Now Xzz wants to know minimum sum of his k friends value.

Input

First line of the input file contains an integer T(0 < T ≤ 20) that indicates how many cases of inputs are there.

The description of each case is given below:

The first line of each case contains two numbers n, k, means there is n pearl necklace and k friends. n, k ≤ 200

Then follow n lines. In ith line there will be n numbers, ai, means the value of ith pearl.1 ≤ ai ≤ 100

Output

One integer means the minimum sum of his k friends value.

SampleInput
2
3 3
1 2 3
5 3
5 2 3 8 2
SampleOutput
14
138
Submit
题目统计信息详细
总AC数5
通过人数2
尝试人数2
总提交量47
AC率4.26%
AC该题后可以添加标签
贴完标签可以获得20ACB。
并且可以获得本题所有提交代码查看权限。
点击标题可以显示标签。
如果你还没认真思考过这题,请不要查看标签
如果您已经通过了该题,请务为该题贴上标签

T^T Online Judge

[BUG反馈] [FAQ] [闽ICP备17026590号-1]
当前版本:3.24 系统时间: