编程介的小学生 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
    关注
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论

报告相同问题?

悬赏问题

  • ¥15 HFSS 中的 H 场图与 MATLAB 中绘制的 B1 场 部分对应不上
  • ¥15 如何在scanpy上做差异基因和通路富集?
  • ¥20 关于#硬件工程#的问题,请各位专家解答!
  • ¥15 关于#matlab#的问题:期望的系统闭环传递函数为G(s)=wn^2/s^2+2¢wn+wn^2阻尼系数¢=0.707,使系统具有较小的超调量
  • ¥15 FLUENT如何实现在堆积颗粒的上表面加载高斯热源
  • ¥30 截图中的mathematics程序转换成matlab
  • ¥15 动力学代码报错,维度不匹配
  • ¥15 Power query添加列问题
  • ¥50 Kubernetes&Fission&Eleasticsearch
  • ¥15 報錯:Person is not mapped,如何解決?