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 ...
随机推荐
- 可拖动FPS显示框(UGUI)
简介 本来是想往上找一个可拖动FPS显示框的(我记得以前有人写过),然而搜了一个多小时都没搜到,索性自己写了一个,花费不到20分钟,看来还是自己动手丰衣足食啊 o(╯□╰)o 效果 上下的Toast不 ...
- 【iOS】XcodeColors插件与CocoaLumberjack工具
工欲善其事必先利其器,好的开发者一定是懂得利用工具来提高自己的效率的,Xcode有很多第三方插件可以使用,最近发现一个可以给控制台着色的工具XcodeColors,结合CocoaLumberjack一 ...
- C# 生成BMP图片
;i<;i++) { Bitmap bmp=new Bitmap(this.pictureBox1.Image); Graphics g=Graphics.FromImage((Image)bm ...
- 静默安装、授权及卸载Microsoft SQL Server、NET Framework、Windows Installer 、ArcGIS License Manager、ArcGIS Engine(Silent install、uninstall and Authorization.. .through Setup Factory)基于Setup Factory
通过Setup Factory写的代码大概有1700行,所以就不整理了.思路如下: 静默安装都是通过去Microsoft 和Esri的官网找到静默安装的命令,然后File.Run(...)或者Shel ...
- 重新想象 Windows 8 Store Apps (50) - 输入: 边缘手势, 手势操作, 手势识别
[源码下载] 重新想象 Windows 8 Store Apps (50) - 输入: 边缘手势, 手势操作, 手势识别 作者:webabcd 介绍重新想象 Windows 8 Store Apps ...
- Csharp: create word file using Open XML SDK 2.5
using System; using System.Collections.Generic; using System.ComponentModel; using System.Data; usin ...
- javascript实现排序算法
准备好好学习js了,js写的第一个排序 先推荐一个js在线编辑工具,RunJS,还不错. 冒泡排序 var arr = [2,4,1,5,3]; function handle(arr){ for(v ...
- 基于进程的Quartz.NET管理系统QuartzService(一)
需求 在处理定时任务大家可能都用过Quartz.NET,但在生产环境中大家肯定也遇到过如下的问题: 发布的时候需要停掉所有的Job,再整个一起打包发布 没有管理界面(其实在github也有几个这方面的 ...
- Failed to install on device ‘emulator-5554′: timeout
启动android模拟器时候如果提示:Failed to install on device ‘emulator-5554′: timeout 这是可能因为卡的原因导致启动超时,解决办法:eclips ...
- 一个页面从输入 URL 到页面加载完的过程中都发生了什么事情?
过程概述 浏览器查找域名对应的 IP 地址: 浏览器根据 IP 地址与服务器建立 socket 连接: 浏览器与服务器通信: 浏览器请求,服务器处理请求: 浏览器与服务器断开连接. 以下为详细解析: ...