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. Installation and Upgrading

    Cumulative Feature Overview Identifies product features available to you when upgrading. This tool r ...

  2. 重新想象 Windows 8.1 Store Apps (90) - 通信的新特性: 通过 HttpBaseProtocolFilter 实现 http 请求的缓存控制,以及 cookie 读写; 自定义 HttpFilter; 其他

    [源码下载] 重新想象 Windows 8.1 Store Apps (90) - 通信的新特性: 通过 HttpBaseProtocolFilter 实现 http 请求的缓存控制,以及 cooki ...

  3. sql: table,view,function, procedure created MS_Description in sql server

    --添加描述 geovindu --https://msdn.microsoft.com/en-us/library/ms180047.aspx --https://msdn.microsoft.co ...

  4. HTML页面放大镜效果

    <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...

  5. [moka同学笔记]yii2.0数据库操作以及分页

    1.model中models/article.php 1 <?php 2 3 namespace app\models; 4 5 use Yii; 6 7 /** 8 * This is the ...

  6. java ftp

    FTPUtil import java.io.File; import java.io.FileOutputStream; import java.io.IOException; import jav ...

  7. vmware screen

    1. Question Description: the screen of the vmware looks small . 2. Solution: 2.1 look the size of sc ...

  8. 解决Spring MVC @ResponseBody返回html中中文字符串乱码问题

    最近有个应用,通过responsebody返回完整的html页面时出现乱码是异常的问题,因为是通过responsebody返回,所以一开始设置了text/plain的字符集,如下: <mvc:a ...

  9. DevExpress.XtraGrid.Views 设置指定行的背景颜色 .

    如需要将指定行的背景设置颜色,可参考以下示例 1.事件:CustomDrawCell 2.示例: private void gridView1_CustomDrawCell(object sender ...

  10. FDO error:Failed to label layer(XXX) for class Default

    描述: A column was specified that does not exist. 出现这个问题的原因在于label features 展示的字段不存在或者为空,只要将其勾选去掉或者换个显 ...