eolymp
bolt
Try our new interface for solving problems
Problems

A Greener World

A Greener World

Suppose that there is a two-dimensional grid. But the grid is a bit special: the grid lines are \textbf{d} units apart instead of \textbf{1}. If such a grid is skewed it will look like the grid shown in picture below (All the squares have become rhombuses and the angle between \textbf{x}-axis and \textbf{y} axis is \textbf{theta} instead of \textbf{90} degree). The intersection of any two grid lines is called a lattice vertex. \includegraphics{https://static.e-olymp.com/content/3c/3c166c1d9d1bd2e75a888891181abca5733e7074.jpg} Initially trees are planted in all the lattice vertices shown with green circles in the picture above. Bill and Marsha buy a land of polygonal shape in this infinite lattice grid-land. All the vertices of the polygon are coincident with one of the lattice vertices. After Bill and Marsha buys the land the government issues a new law: "\textit{Two make the landscape even greener everyone must plant another plant at the center of each smallest rhombus}". These new plants are shown with red circles in the picture above. Given the shape of the land of Bill and Marsha your job is to suggest them how many new trees must be planted by them within their land according to the new law imposed by the government? You can assume that on trees have zero radius and trees planted on the boundary of the land of Bill and Marsha are not considered inside the land. OOPS! I forgot to tell you that you also need to find out the area of the land of Bill and Marsha. \InputFile The input file contains at most \textbf{15} sets of inputs. The description of each set is given below: Each set starts with three integers \textbf{d} (\textbf{0} < \textbf{d} < \textbf{10000}), \textbf{theta} (\textbf{44º} < \textbf{theta} < \textbf{136º}) and \textbf{N}. The meaning of \textbf{d} and \textbf{theta} is given in the problem statement and \textbf{N} denotes the number of vertices of the polygonal land. Each of the next \textbf{N} lines contains two integers \textbf{x}, \textbf{y} (\textbf{0} ≤ \textbf{x}, \textbf{y} ≤ \textbf{100000}) which denote the coordinate of a vertex of the polygonal shaped land. The coordinates of the vertices are given in clockwise or anti-clockwise order along the edges of the polygonal shaped land. Input is terminated by a case where the value of \textbf{d}, \textbf{theta} and \textbf{N} are zero. \OutputFile For each set of input output two integers. The first integer denotes the number of new plants to be planted in the land of Bill and Marsha and the second integer denotes area of the land of Bill and Marsha rounded to the nearest integer.
Time limit 3 seconds
Memory limit 64 MiB
Input example #1
10 45 4
0 0 
0 1000
999 1000
1000 0
10 76 5
2 -2
4 6
-3 5
-5 1
-2 2
0 0 0
Output example #1
999500 70675323
33 3493