传送门:Cool Points

题意:给一个圆心为原点的圆和一些线段,问所有线段两端点与圆心连线构成的角度总和占总360度的百分比。

分析:首先将所有线段的两端点变成极角,然后排序(范围[-PI,PI],即从x轴负方向逆时针转一圈),如果某一线段极角值之差大于PI,构成的角度值肯定不是<AOB,而是<AOX+<XOB。因此处理好这种情况,从x轴负向走一圈计值即可。

#include <algorithm>
#include <cstdio>
#include <cstring>
#include <cmath>
#define N 1010
#define PI acos(-1.0)
using namespace std;
struct node
{
double angle;
int num;
node(){}
node(double angle,int num):angle(angle),num(num){}
bool operator<(const node &a)const{
return angle<a.angle;
}
}e[N];
int tot;
void addseg(double x,double y)
{
e[tot++]=node(x,);
e[tot++]=node(y,-);
}
int main()
{
int T,n,r,cas=;
scanf("%d",&T);
while(T--)
{
scanf("%d%d",&n,&r);
tot=;
for(int i=;i<=n;i++)
{
double x1,y1,x2,y2;
scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
double a1=atan2(y1,x1),a2=atan2(y2,x2);
if(a1<a2)swap(a1,a2);
if(a1-a2>PI)
{
addseg(a1,PI);
addseg(-PI,a2);
}
else addseg(a2,a1);
}
sort(e,e+tot);
int cnt=;
double ans=,last=-PI;
for(int i=;i<tot;i++)
{
if(cnt==)//前面的线段刚好成对
{
ans+=e[i].angle-last;
}
cnt+=e[i].num;
last=e[i].angle;
}
ans+=PI-last;
printf("Case %d: %.2lf%%\n",cas++,ans/(*PI)*);
}
}

uva 11355(极角计算)的更多相关文章

  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 1606 (极角排序) Amphiphilic Carbon Molecules

    如果,没有紫书上的翻译的话,我觉得我可能读不懂这道题.=_=|| 题意: 平面上有n个点,不是白点就是黑点.现在要放一条直线,使得直线一侧的白点与另一侧的黑点加起来数目最多.直线上的点可以看作位于直线 ...

  3. UVA 11355 Cool Points(几何)

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

  4. UVA - 1625 Color Length[序列DP 代价计算技巧]

    UVA - 1625 Color Length   白书 很明显f[i][j]表示第一个取到i第二个取到j的代价 问题在于代价的计算,并不知道每种颜色的开始和结束   和模拟赛那道环形DP很想,计算这 ...

  5. 【转】UVa Problem 100 The 3n+1 problem (3n+1 问题)——(离线计算)

    // The 3n+1 problem (3n+1 问题) // PC/UVa IDs: 110101/100, Popularity: A, Success rate: low Level: 1 / ...

  6. UVA - 1625 Color Length[序列DP 提前计算代价]

    UVA - 1625 Color Length   白书 很明显f[i][j]表示第一个取到i第二个取到j的代价 问题在于代价的计算,并不知道每种颜色的开始和结束   和模拟赛那道环形DP很想,计算这 ...

  7. UVa 1606 Amphiphilic Carbon Molecules (扫描法+极角排序)

    题意:平面上有 n 个点,每个点不是黑的就是白的,现在要放一个隔板,把它们分成两部分,使得一侧的白点数加上另一侧的黑点数最多. 析:这个题很容易想到的就是暴力,不妨假设隔板至少经过两个点,即使不经过也 ...

  8. UVa 109 - SCUD Busters(凸包计算)

    题目来源:https://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=3&pa ...

  9. UVA 11076 Add Again 计算对答案的贡献+组合数学

    A pair of numbers has a unique LCM but a single number can be the LCM of more than one possiblepairs ...

随机推荐

  1. 总线接口与计算机通信(一)I2C总线

    1.  I2C总线的基本概念    1)发送器(Transmitter):发送数据到总线的器件    2)接收器(Receiver):从总线接收数据的器件    3)主机(Master):初始化发送. ...

  2. VC 2005 解决方案的目录结构设置和管理

    VC 2005 解决方案的目录结构设置和管理   Roger (roger2yi@gmail.com)   一个中等规模的解决方案通常都会包含多个项目,其中一些项目产出静态库,一些产出动态库,一些用于 ...

  3. Oracle多表的简单查询

    Oracle多表的简单查询 .多表查询 多表查询是指基于两个和两个以上的表或是视图的查询. 问题:显示雇员名,雇员工资及所在部门的名字[笛卡尔集]? select t.ename,t.sal,t1.d ...

  4. Eclipse用法和技巧十七:覆盖父类方法

    在学校里面学习java,遇到访问权限修饰符一直停留在public是公有的,外面可以访问:protected是对子类可见的,外部不可以访问:private仅在本类中可见.工作之后,接触到了java代码多 ...

  5. Writing a Windows Shell Extension(marco cantu的博客)

    Writing a Windows Shell Extension This is a technical article covering the content of my last week s ...

  6. WCF随笔3----消息编码器

    原文:WCF随笔3----消息编码器 我们都知道,message是wcf通信框架进行通信的最基本的单位,但是wcf开发人员其实根本不需要直接与message打交道,一样能够写好wcf相关的程序.这是因 ...

  7. 基于visual Studio2013解决面试题之0510连续数之和

     题目

  8. 基于visual Studio2013解决面试题之0410计算二进制中1的个数

     题目

  9. C++经典书目索引及资源下载

    C++经典书目索引: 严重申明 : 本博文未经原作者(jerryjiang)同意,不论什么人不得转载和抄袭 ! Essential C++ 中文版 层次:0基础 导读:<Essential C+ ...

  10. OpenCV中遇到Microsoft C++ 异常 cv::Exception

    我在实现<OpenCV2计算机视觉编程手册>第2章 2.2 节 存取像素值 中的椒盐噪声例子中遇到的程序错误. 原始输入程序: #include <opencv2/core/core ...