编程介的小学生 2017-09-04 12:07 采纳率: 20.5%
浏览 795
已采纳

Chopsticks

In China, people use a pair of chopsticks to get food on the table, as we all know, the pair of chopsticks are of the same, but Miss Sundance is a bit different, as a lazy girl, she pluses a spoon to the end of one of her chopsticks, thus she can drink her favorite soup more easily.
But it comes to a serious problem. The lengths of the two chopsticks are now different. As you may guess, the length of them should be as close as possible. To make things clearer, for the set of chopsticks with lengths A, B (A <= B), (A - B) ^ 2 is called the 'badness' of the set.

It's September 11th, Miss Sundance��s birthday! She invited many people to join her birthday party, and would like to introduce her way of using chopsticks. So, She should prepare as many sets of chopsticks as possible. But Miss Sundance suddenly discovered that her chopsticks are of quite different lengths! She should find a way of composing the most sets of chopsticks, with the total badness (<= 2 ^ 31 - 1) of all the sets is minimized.

Input

The first line in the input contains a single integer T, indicating the number of test cases. Each test case contains two lines. The first line begins with an positive integer N1 (1 =< N1 <= 500), the number of chopsticks with spoon, then N1 numbers follow, which denote the lengths of correspondent chopsticks, the second line, describes the normal chopsticks�� lengths, is the same format as the first one. (1 =< N2 <= 500)

Output

For each test case in the input, print a line containing the minimal total badness of all the sets.

Sample Input

1
2 1 2
2 1 2

Sample Output

0

  • 写回答

1条回答 默认 最新

  • threenewbee 2017-09-18 21:27
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥17 pro*C预编译“闪回查询”报错SCN不能识别
  • ¥15 微信会员卡接入微信支付商户号收款
  • ¥15 如何获取烟草零售终端数据
  • ¥15 数学建模招标中位数问题
  • ¥15 phython路径名过长报错 不知道什么问题
  • ¥15 深度学习中模型转换该怎么实现
  • ¥15 Stata外部命令安装问题求帮助!
  • ¥15 从键盘随机输入A-H中的一串字符串,用七段数码管方法进行绘制。提交代码及运行截图。
  • ¥15 TYPCE母转母,插入认方向
  • ¥15 如何用python向钉钉机器人发送可以放大的图片?