Pizza!
Time limit1sMemory limit128 MB
Given nuggets at polar positions on a unit circle, find the maximum number of equal-angle radial slices so every slice holds the same nugget count.
- Level
Medium6 of 10
- Topics
- Math, Number theory, Geometry, Sorting
- Solved
- No attempts yet
Problem
The results have all been announced, and it is finally time for the most important part of the contest: eating pizza.
But the pizza is shaped so oddly that we have to write code again.
The pizza is a circle of radius , and a few nuggets sit on top of it.
When cutting the pizza, all three of the following conditions must hold:
- Every cut must run along a radius, from the center of the pizza straight out to the edge.
- No nugget may ever be cut.
- After all cuts are made, every resulting piece must be the same size, and every piece must hold the same number of nuggets.
Even though the contest is over, a fight is about to break out over mere nuggets. Since there are many participants, you want to cut the pizza into as many pieces as possible. Determine the maximum number of pieces the pizza can be cut into while satisfying the conditions above.
You may also choose not to cut the pizza at all. In that case the pizza is a single piece.
Input
The first line contains the number of test cases .
The first line of each test case contains the number of nuggets ().
Each of the next lines gives the position of one nugget as two real numbers and , separated by a space.
is the angle measured counterclockwise from the center of the pizza and satisfies .
is the distance from the center of the pizza to the nugget and satisfies . (The pizza has radius .)
A nugget is treated as a single point with no size, and no two nuggets occupy exactly the same position (though two nuggets may share the same angle while differing in distance ).
Output
For each test case, first print Data Set K: (where is the test case number), then print s slices where is the maximum number of pieces the pizza can be cut into.
For example, if the answer for the first test case is , print Data Set 1: 1 slices.
Print one blank line between the outputs of consecutive test cases.
Hint
Do not worry about grammatical awkwardness in the output (for instance, printing 1 slices even for a single piece).