Harry Potter and J.K.Rowling
Time Limit: 2000/1000 MS (Java/Others) Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 685 Accepted Submission(s): 210
Problem Description In July 31st, last month, the author of the famous novel series J.K.Rowling celebrated her 46th birthday. Many friends gave their best wishes. They gathered together and shared one large beautiful cake.
Rowling had lots of friends, and she had a knife to cut the cake into many pieces. On the cake there was a cherry. After several cuts, the piece with the cherry was left for Rowling. Before she enjoyed it, she wondered how large this piece was, i.e., she wondered how much percentage of the cake the piece with the only cherry has.
Input First line has an integer T, indicating the number of test cases.
T test cases follow. The first line of each test case has one number r (1 <= r <= 10000) and one integer n (0 <= n <= 2000), indicating the radius of the cake and the number of knife cuts. n lines follow. The i-th line has four numbers, x1, y1, x2, y2. (x1, y1) and (x2, y2) are two points on the i-th cut. (-10000 <= x1, y1, x2, y2 <= 10000) The last line of each case has two number x, y, indicating the coordinate(x, y) of the cherry.
Technical Specification
2. The center of the cake is always on the point (0, 0).
3. The cherry was always on the cake and would not be on the knife cuts.
Output For each test case, in one line output the case number and the percentage the piece with the cherry has of whole original cake, rounded to five fractional digits.
Sample Input
1 1.00 2 -1.00 0.00 1.00 0.00 0.00 -1.00 0.00 1.00 0.50 0.50
Sample Output
Case 1: 25.00000%题目意思:有一块半径为r的圆形蛋糕,其中心在原点,有一个人在某一个点(x,y),现把蛋糕按两点所在直线切蛋糕,求切了n次后,这个人所在蛋糕的面积占总面积的百分比。
很容易想到计算每一条直线与圆的交点,半平面交求出多边形,然后求多边形与圆的面积交,
HDU坑爹,eps=1e-8就wa,1e-5就ac,蛋疼。
代码:
/* *********************************************** Author :_rabbit Created Time :2014/5/4 15:03:55 File Name :20.cpp ************************************************ */ #pragma comment(linker, "/STACK:102400000,102400000") #include#include #include #include #include #include #include #include #include #include #include #include #include #include