UVA 11355 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(几何)的更多相关文章
- UVA 11355 Cool Points( 极角计算 )
We have a circle of radius R and several line segments situated within the circumference of this cir ...
- UVA 10869 - Brownie Points II(树阵)
UVA 10869 - Brownie Points II 题目链接 题意:平面上n个点,两个人,第一个人先选一条经过点的垂直x轴的线.然后还有一个人在这条线上穿过的点选一点作垂直该直线的线,然后划分 ...
- uva 11355(极角计算)
传送门:Cool Points 题意:给一个圆心为原点的圆和一些线段,问所有线段两端点与圆心连线构成的角度总和占总360度的百分比. 分析:首先将所有线段的两端点变成极角,然后排序(范围[-PI,PI ...
- UVA 11796 Dog Distance(几何)
Dog Distance [题目链接]Dog Distance [题目类型]几何 &题解: 蓝书的题,刘汝佳的代码,学习一下 &代码: // UVa11796 Dog Distance ...
- UVa 11971 - Polygon(几何概型 + 问题转换)
链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- UVa 11346 - Probability(几何概型)
链接: https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem& ...
- UVA 270 Lining Up (几何 判断共线点)
Lining Up ``How am I ever going to solve this problem?" said the pilot. Indeed, the pilot was ...
- uva 11178二维几何(点与直线、点积叉积)
Problem D Morley’s Theorem Input: Standard Input Output: Standard Output Morley’s theorem states tha ...
- uva 11665 Chinese Ink (几何+并查集)
UVA 11665 随便给12的找了一道我没做过的几何基础题.这题挺简单的,不过uva上通过率挺低,通过人数也不多. 题意是要求给出的若干多边形组成多少个联通块.做的时候要注意这题是不能用double ...
随机推荐
- C#设计模式——模板方法(Template Method)
一.概述在软件开发中,对某一项操作往往有固定的算法结构,而具体的子步骤会因为不同的需要而有所不同.如何可以在稳定算法结构的同时来灵活应对子步骤变化的需求呢?二.模板方法模板方法是一种常见的设计模式,它 ...
- 深入.NET内测题
一 选择题 1) 以下关于序列化和反序列化的描述错误的是( C). a) 序列化是将对象的状态存储到特定存储介质中的过程 b) 二进制格式化器的Serialize()和D ...
- Aspose.Word 操作word复杂表格 拆分单元格 复制行 插入行 文字颜色
private void button3_Click(object sender, EventArgs e) { object savePathWord =&q ...
- 如何使用mybatis《二》
前边阐述了如何在java项目中使用mybatis,我们使用的是映射文件的方式,在获得具体的数据操作方法时需要传入映射文件中namespace+“.”方法名称,这种方式有时候会感觉很不爽,很麻烦.我们在 ...
- linux线程控制&线程分离
线程概念 线程,有时被称为轻量级进程(Lightweight Process,LWP),是程序执行流的最小单元. 线程是程序中一个单一的顺序控制流程.进程内一个相对独立的.可调度的执行单元,是系统独立 ...
- Form.action传值问题
通过浏览器地址栏输入url并通过?传递参数请求资源时,?后面的参数叫做 "查询字符串",会触发后台Servlet的doGet(),因为通过浏览器地址栏直接访问的方式是GET方式. ...
- Web安全开发注意事项
1.sql注入:这个很常规了,不要拼字符串以及过滤关键字都可以防住,需要注意的是,Cookie提交的参 数也是可以导致注入漏洞的.2.旁注:就是说在保证自己的程序没问题的同时,也要保证同台服务器的其他 ...
- C语言指针的长度和类型
本文地址:http://www.cnblogs.com/archimedes/p/point-length-type.html,转载请注明源地址. 如果考虑应用程序的兼容性和可移植性,指针的长度就是一 ...
- OC--代理模式
一,代理设计模式的场合: 当对象A发生了一些行为,想告知对象B (让对象B成为对象A的代理对象) 对象B想监听对象A的一些行为 (让对象B成为对象A的代理对象) 当对象A无法处理某些行为的时候,想让对 ...
- 斯坦福iOS7公开课7-9笔记及演示Demo
这一部分主要介绍了iOS的绘图.手势.协议.block.力学特效动画(包括重力.碰撞.吸附等)以及自动布局的内容. 1.绘图.手势 (1)调用一个自定义的UIView时,可以使用awakeFromNi ...