bnu 34982 Beautiful Garden
Beautiful Garden
There are n trees planted in lxhgww's garden. You can assume that these trees are planted along the X-axis, and the coordinate of ith tree
is xi.
But in recent days, lxhgww wants to move some of the trees to make them look more beautiful. lxhgww will recognize the trees as beautiful if and only if the distance between any adjacent trees is the
same.
Now, lxhgww wants to know what is the minimum number of trees he need to move.
Just to be clear, after moving, there should still be n trees in the X-axis.
Input
The first line of the input contains a single integer T, which is the number of test cases.
For each case,
- The first line contains an integers number n (1 ≤ n ≤ 40), representing the number of trees lxhgww planted;
- The second line contains n integers numbers, the ith number represents xi.
(-1000000000 ≤ xi ≤ 1000000000)
Output
For each case, first output the case number as "Case #x: ", and x is the case number. Then output a single number, representing the minimum number of trees lxhgww needs to
move.
Sample Input
1
4
1 3 6 7
Sample Output
Case #1: 1
Source
2014 ACM-ICPC Beijing Invitational
Programming Contest
題解及代碼:
#include
#include
#include
#include