Cool Points

We have a circle of radius R and several line segments situated within the circumference of this circle. Let’s define a cool point to be a point on the circumference of this circle so that the line segment that is formed by this point and the centre of the circle makes no intersection with any of the given line segments.

For this problem, you have to find out the percentage of cool points from all possible points on the circumference of the given circle.

Input

The input file starts with an integer T(T<1000) that indicates the number of test cases. Each case starts with 2 integers N(0 <= N < 100) and R(0 < R < 1001). N represents the number of line segments and R represents the radius of the circle. Each of the next N lines contains 4 integers in the order x1, y1,x2 and y2. (x1, y1)(x2, y2) represents a line segment.

You can assume that all the line segments will be inside the circle and no line segment passes through the origin. Also consider the center of the circle to be on the origin.

Output

For each input, output the case number followed by the percentage, rounded to 2 decimal places, of cool points. Look at the output for exact format.

Sample Input

Output for Sample Input

2

1 10

2 0 0 2

0 5

Case 1: 75.00%

Case 2: 100.00%

view code#include <bits/stdc++.h>

using namespace std;
double PI = acos(-1.0);
int _, cas=1, n, r; struct event
{
double x;
int y;
bool operator < (const event &o) const{
return x<o.x;
}
event() {}
event(double x, int y):x(x),y(y) {}
}e[4321];
int ecnt; void addseg(double a, double b)
{
if(a>b) swap(a,b);
e[ecnt++] = event(a, 1);
e[ecnt++] = event(b, -1);
} int main()
{
// freopen("in.txt", "r", stdin);
cin>>_;
while(_--)
{
scanf("%d%d", &n, &r);
ecnt = 0;
double a,b,c,d;
for(int i=0; i<n; i++)
{
scanf("%lf%lf%lf%lf", &a, &b, &c, &d);
double x = atan2(b,a), y = atan2(d,c);
if(x<y) swap(x, y);
if(x-y>PI)
{
addseg(-PI, y);
addseg(x, PI);
}
else addseg(x, y);
}
int eventnum = 0;
sort(e, e+ecnt);
double last = -PI, ans = 0.0;
for(int i=0; i<ecnt; i++)
{
if(eventnum==0)//这里很经典,记下
{
ans += e[i].x - last;
}
eventnum += e[i].y;
last = e[i].x;
}
ans += PI - last;
printf("Case %d: %.2f%%\n", cas++, (ans/(PI*2)*100));
}
return 0;
}

UVA 11355 Cool Points(几何)的更多相关文章

  1. UVA 11355 Cool Points( 极角计算 )

    We have a circle of radius R and several line segments situated within the circumference of this cir ...

  2. UVA 10869 - Brownie Points II(树阵)

    UVA 10869 - Brownie Points II 题目链接 题意:平面上n个点,两个人,第一个人先选一条经过点的垂直x轴的线.然后还有一个人在这条线上穿过的点选一点作垂直该直线的线,然后划分 ...

  3. uva 11355(极角计算)

    传送门:Cool Points 题意:给一个圆心为原点的圆和一些线段,问所有线段两端点与圆心连线构成的角度总和占总360度的百分比. 分析:首先将所有线段的两端点变成极角,然后排序(范围[-PI,PI ...

  4. UVA 11796 Dog Distance(几何)

    Dog Distance [题目链接]Dog Distance [题目类型]几何 &题解: 蓝书的题,刘汝佳的代码,学习一下 &代码: // UVa11796 Dog Distance ...

  5. UVa 11971 - Polygon(几何概型 + 问题转换)

    链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  6. UVa 11346 - Probability(几何概型)

    链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...

  7. UVA 270 Lining Up (几何 判断共线点)

     Lining Up  ``How am I ever going to solve this problem?" said the pilot. Indeed, the pilot was ...

  8. uva 11178二维几何(点与直线、点积叉积)

    Problem D Morley’s Theorem Input: Standard Input Output: Standard Output Morley’s theorem states tha ...

  9. uva 11665 Chinese Ink (几何+并查集)

    UVA 11665 随便给12的找了一道我没做过的几何基础题.这题挺简单的,不过uva上通过率挺低,通过人数也不多. 题意是要求给出的若干多边形组成多少个联通块.做的时候要注意这题是不能用double ...

随机推荐

  1. c++转C#

    //c++:HANDLE(void   *)          ----    c#:System.IntPtr        //c++:Byte(unsigned   char)     ---- ...

  2. Azure开发者任务之六:使用WCF Service Web Role

    在本文中,我们将会在local development fabric上创建一个WCF服务角色,然后在一个控制台应用程序中使用它. WCF服务角色可以让我们创建一个WCF服务,并且把它托管在Window ...

  3. 重新想象 Windows 8 Store Apps (67) - 后台任务: 推送通知

    [源码下载] 重新想象 Windows 8 Store Apps (67) - 后台任务: 推送通知 作者:webabcd 介绍重新想象 Windows 8 Store Apps 之 后台任务 推送通 ...

  4. 容器--Collection和AbstractCollection

    一.前言 容器是JAVA中比较重要的一块,整个体系设计得非常好,同时对于代码学习来说也是比较好的范例.同时很多面试官也比较喜欢用容器来考察面试者的基础知识,所以掌握好容器还是比较重要的.本文主要总结一 ...

  5. (旧)子数涵数·DW——网页制作的流程

    PS:这是我很早以前的一个废掉的项目. 当时用的还是table排版,现在基本都是div了吧. 这个项目前段时间,我还抢救过一次,后来还是放弃了. 先行.网页制作的流程分为哪些呢? 一.网站策划(当时, ...

  6. 那一夜,我们..奋笔疾书敲出的--->>库存管理系统

    说了会再见,最近好吗?无论你在哪里>也许你在温暖的家,或许你在身在异乡的城市;或许你高高的峰顶放生高歌,或许你还在陡峭的山峰半空努力攀爬.......相信我们都会登上顶峰,"会当凌绝顶 ...

  7. HttpController的激活

    Web API调用请求的目标是定义在某个HttpController类型中的某个Action方法,所以消息处理管道的最终需要激活目标HttpController对象.调用请求的URI会携带目标Http ...

  8. mongodb 基本指令学习 (2)

    db.collectionname.find(<criteria>, <projection>) <criteria>   可选   类型 文档    文档的过滤条 ...

  9. RHEL7虚拟机实验快照

    配置虚拟机连接网络 首先确保NetworkManager服务正常运行 [root@administrator ~]# systemctl status NetworkManager ● Network ...

  10. CSS 去掉inline-block元素间隙的几种方法

    最近做移动端页面时,经常会用到inline-block元素来布局,但无可避免都会遇到一个问题,就是inline-block元素之间的间隙.这些间隙会导致一些布局上的问题,需要把间隙去掉.对于inlin ...