Welcome to ZOJ
 Problem Sets Information Select Problem Runs Ranklist
ZOJ Problem Set - 3855
Curve in Circle

Time Limit: 2 Seconds      Memory Limit: 65536 KB

Have you ever played this game? There's a large board with a round hole, and in the round hole there's a round part which contains a convex hole in it. You've given a pen to draw some curves using the board and the round part. It's easy to know that when drawing the curves, the nib, the center of the round part and the center of the round hole must be in a straight line, just like the picture below.

Now the question is: after drawing the curves along the whole convex hole, what's the total length of the curves?

#### Input

There'll be several test cases, for each test case, there will be 3 integers R (0 < R ≤ 1000), r (0 < rR) and n (3 ≤ n ≤ 100) in the first line. Here R is the radius of round hole, r is the radius of the round part, and n is number of vertex of the convex hole. Then in the next n lines, each line contains 2 integers xi and yi, which are one vertex's coordinates refer to center of the round part.

To simplify the question, we guarantee that the convex hole is strictly inside the round part, and the center of the round part is strictly inside the convex hole.

#### Output

For each test case, please output the total curves length in one line, rounded to 3 decimal points.

```5 3 3
0 1
1 -1
-1 -1
5 5 4
1 1
1 -1
-1 -1
-1 1```

#### Sample Output

```11.524
8.000```

Source: 2013 ACM/ICPC Asia Regional Changsha Online contest
Submit    Status