The Clock with Presents
Limits: 2 sec., 256 MiB
Santa Claus also has prepared presents for his little helpers, and hung them on a special clock.
The clock is an infinite grid with integer coordinates of its vertices. The clock arrow – is an infinite ray, starting from coordinates X,Y.
Santa Claus has hung presents at some vertices. Elves can retrieve a present only when the clock arrow is pointing to this present, and there are no other presents in between that the arrow is intersecting as well.
Elves are curious - how many full turns (360 degrees) will the clock arrow do before elves collect all presents from the clock.
We do not know the initial time that the clock is showing, however we know that is not currently pointing at any present.
Input
In the first row, two integer numbers X, Y - coordinates of the clock arrow beginning position.
In the second row, one number N - number of presents, that Santa Clause has hung.
In next N rows are two integer numbers - \(Px_i, Py_i\) - presents coordinates, that Santa Clause has hung on a clock.
Output
One integer number - how many full turns the clock arrow will make.
Constraints
\(-10^9 \leq X,Y,Px_i,Py_i \leq 10^9\)
\(1 \leq N \leq 10^5\)
It is guaranteed, that no two gifts are in the same vertex, and the present is not located at the beginning of the clock arrow.
Samples
| Input (stdin) | Output (stdout) |
|---|---|
| 4 4 4 4 5 4 6 0 0 1 1 | 1 |
| Input (stdin) | Output (stdout) |
|---|---|
| 0 0 12 0 1 0 2 0 3 0 4 1 0 2 0 3 0 4 0 -1 -1 -2 -2 -3 -3 -4 -4 | 3 |
| Element Type | Created | Who | Problem | Compiler | Result | Time (sec.) | Memory (MiB) | # | Actions |
|---|