| <p> | |
| <strong>N</strong> groups of people are heading to the beach today! | |
| The <em>i</em>th group is bringing a circular umbrella with a radius <strong>R<sub>i</sub></strong> meters. | |
| </p> | |
| <p> | |
| The beach has <strong>M</strong> acceptable points at which umbrellas may be screwed into the sand, | |
| arranged in a line with 1 meter between each adjacent pair of points. | |
| Each group of people will choose one such point at which to position the center of their umbrella. | |
| </p> | |
| <p> | |
| Of course, it's no good if any pair of umbrellas collide (that is, if the intersection of their circles has a positive area). | |
| The <strong>N</strong> groups will work together to place their umbrellas such that this doesn't happen. | |
| However, they're wondering in how many distinct ways that can be accomplished. | |
| Two arrangements are considered to be distinct if they involve at least one group placing their umbrella in a different spot. | |
| As this quantity may be very large, they're only interested in its value modulo 1,000,000,007. | |
| </p> | |
| <p> | |
| Note that it might be impossible for all of the groups to validly place their umbrellas, yielding an answer of 0. | |
| </p> | |
| <h3>Input</h3> | |
| <p> | |
| Input begins with an integer <strong>T</strong>, the number of days the beach is open. | |
| For each day, there is first a line containing two space-separated integers, <strong>N</strong> and <strong>M</strong>. | |
| Then, <strong>N</strong> lines follow, the <em>i</em>th of which contains a single integer, <strong>R<sub>i</sub></strong>. | |
| </p> | |
| <h3>Output</h3> | |
| <p> | |
| For the <em>i</em>th day, print a line containing "Case #<strong>i</strong>: " | |
| followed by the number of valid umbrella arrangements, modulo 1,000,000,007. | |
| </p> | |
| <h3>Constraints</h3> | |
| <p> | |
| 1 ≤ <strong>T</strong> ≤ 100 <br /> | |
| 1 ≤ <strong>N</strong> ≤ 2,000 <br /> | |
| 1 ≤ <strong>M</strong> ≤ 1,000,000,000 <br /> | |
| 1 ≤ <strong>R<sub>i</sub></strong> ≤ 2,000 <br /> | |
| </p> | |
| <h3>Explanation of Sample</h3> | |
| <p> | |
| In the second case there are six possibilities. If the radius-1 umbrella is placed at the far-left point, then the radius-2 umbrella can be placed at either of the two right-most points. If the radius-1 umbrella is placed at the second point from the left, then the radius-2 umbrella must be placed at the right-most point. That's three possibilities so far, and we can mirror them to produce three more. | |
| </p> | |