Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|

Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |

Language: Twirl Around
Description Let's think about a bar rotating clockwise as if it were a twirling baton moving on a planar surface surrounded by a polygonal wall (see Figure 1). Figure 1. A bar rotating in a polygon Initially, an end of the bar (called "end A") is at (0,0), and the other end (called "end B") is at (0, The bar turns fixing a touching point as the center. The center changes as a new point touches the wall. Your task is to calculate the coordinates of the end A when the bar has fully turned by the given count Figure 2. Examples of turning bars In Figure 2, some examples are shown. In cases (D) and (E), the bar is stuck prematurely (cannot rotate clockwise anymore with any point touching the wall as the center) before You can assume the following: When the bar's length Input The input consists of multiple datasets. The number of datasets is no more than 100. The end of the input is represented by "0 0 0". The format of each dataset is as follows: L R N
X_{1} Y_{1}
X_{2} Y_{2}
... X_{N} Y_{N}
The vertices of the polygon are arranged in a counter-clockwise order. You may assume that the polygon is
L ≤ 500.0,
1.0 ≤ R ≤ 10.0,
3 ≤ N ≤ 100,
-1000 ≤ X_{i} ≤ 1000,
-1000 ≤ Y_{i} ≤ 1000,
X_{1} ≤ -1, Y_{1} = 0,
X_{2} ≥ 1, Y_{2} = 0.Output For each dataset, print one line containing Sample Input 4.0 2.0 8 -1 0 5 0 5 -2 7 -2 7 0 18 0 18 6 -1 6 4.0 2.0 4 -1 0 10 0 10 12 -1 12 4.0 1.0 7 -1 0 2 0 -1 -3 -1 -8 6 -8 6 6 -1 6 4.0 2.0 6 -1 0 10 0 10 3 7 3 7 5 -1 5 5.0 2.0 6 -1 0 2 0 2 -4 6 -4 6 6 -1 6 6.0 1.0 8 -1 0 8 0 7 2 9 2 8 4 11 4 11 12 -1 12 0 0 0 Sample Output 16.0 0.0 9.999999999999998 7.4641016151377535 0.585786437626906 -5.414213562373095 8.0 0.0 6.0 0.0 9.52786404500042 4.0 Hint Note that the above sample input corresponds to the cases in Figure 2. For convenience, in Figure 3, we will show an animation and corresponding photographic playback for the case (C). Source |

[Submit] [Go Back] [Status] [Discuss]

All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di

Any problem, Please Contact Administrator