| <p> |
| The night sky can be modeled as an infinite 2D plane. There are <strong>N</strong> stars at distinct positions on this plane, the <strong>i</strong>th of which is at coordinates |
| (<strong>X<sub>i</sub></strong>, <strong>Y<sub>i</sub></strong>). |
| </p> |
|
|
| <p> |
| A boomerang constellation is a pair of distinct equal-length line segments which share a single endpoint, such that both endpoints of each segment coincide with a star's location. |
| </p> |
|
|
| <p> |
| Two boomerang constellations are distinct if they're not made up of the same unordered pair of line segments. How many distinct boomerang constellations can you spot? |
| </p> |
|
|
|
|
| <h3>Input</h3> |
| <p> |
| Input begins with an integer <strong>T</strong>, the number of nights on which you look out at the sky. |
| For each night, there is first a line containing the integer <strong>N</strong>. Then, <strong>N</strong> |
| lines follow, the <strong>i</strong>th of which contains the space-separated integers |
| <strong>X<sub>i</sub></strong> and <strong>Y<sub>i</sub></strong>. |
| </p> |
|
|
|
|
| <h3>Output</h3> |
| <p> |
| For the <strong>i</strong>th night, print a line containing "Case #<strong>i</strong>: " followed by |
| the number of boomerang constellations in the night sky. |
| </p> |
|
|
|
|
| <h3>Constraints</h3> |
| <p> |
| 1 ≤ <strong>T</strong> ≤ 50 <br /> |
| 1 ≤ <strong>N</strong> ≤ 2,000 <br /> |
| -10,000 ≤ <strong>X<sub>i</sub></strong>, <strong>Y<sub>i</sub></strong> ≤ 10,000 <br /> |
| </p> |
|
|
|
|
|
|
| <h3>Explanation of Sample</h3> |
| <p> |
| On the first night, every pair of stars is a unique distance apart, so there are no boomerang constellations. On the second night, there are 4 boomerang constellations. One of them consists of the line segments (0,0)-(0,2) and (0,2)-(0,4). |
| </p> |
|
|
|
|
|
|