```#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#define INint 2147483647
#define pi acos(-1.0)
#define eps 1e-4
using namespace std;
#define N 100102
#define M 22

typedef struct point
{
double x,y;
point(double x=,double y=):x(x),y(y){}
}Vector;

{
return deg/180.0*pi;
}

int dcmp(double x)
{
if(fabs(x)<eps) return ;
return x<?-:;
}
Vector operator  + (Vector A,Vector B){return Vector(A.x+B.x,A.y+B.y);}
Vector operator  -  (point A,point B){return Vector(A.x-B.x,A.y-B.y);  }
Vector operator  *  (Vector A,double p){return Vector(A.x*p,A.y*p);}
Vector operator  /  (Vector A,double p){return Vector(A.x/p,A.y/p);}
bool operator ==  (const point& a,const point& b){return dcmp(a.x-b.x)==&&dcmp(a.y-b.y)==;}
bool operator < (const point& a,const point& b){return a.x<b.x ||(a.x==b.x&&a.y<b.y);}
double Cross(Vector A,Vector B){return A.x*B.y-A.y*B.x;}   //叉积 ，大于零说明B在A的左边。小于零说明B在A的右边
double Dot(Vector A,Vector B){return A.x*B.x+A.y*B.y;}    //点积
double length(Vector A){return sqrt(Dot(A,A));}              //向量长度

double DistanceToSegment(point P,point A,point B)
{
if(A==B) return length(P-A);
Vector v1=B-A,v2=P-A,v3=P-B;
if(dcmp(Dot(v1,v2))<)  return length(v2);
else if(dcmp(Dot(v1,v3))>) return length(v3);
else return fabs(Cross(v1,v2))/length(v1);
}

point p[];
double ra[];

int main()
{
int n,i,j;
while(scanf("%d",&n)!=EOF && n)
{
for(i=;i<n;i++)
scanf("%lf%lf%lf",&p[i].x,&p[i].y,&ra[i]);
double maxi = 0.0;
int S = *;
for(i=;i<S;i++)
{
point A,B,C;
A = point(0.0,0.0);
double sum = 0.0;
for(j=;j<n;j++)
{
C = p[j];
double dis = DistanceToSegment(C,A,B);
if(dis >= ra[j])
continue;
sum += 2.0*sqrt(ra[j]*ra[j]-dis*dis);
}
maxi = max(maxi,sum);
}
printf("%.3lf\n",maxi);
}
return ;
}```

```#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#define pi acos(-1.0)
using namespace std;
#define N 100102
#define M 22

struct node
{
double x,y,r;
}p[];

int getPlane(double nx,double ny)
{
if(nx >  && ny > )
return ;
else if(nx >  && ny < )
return ;
else if(nx <  && ny < )
return ;
else if(nx <  && ny > )
return ;
else
return ;
}

double dis(int nx,int ny)
{
return sqrt(nx*nx + ny*ny);
}

int main()
{
int n,i,j;
while(scanf("%d",&n)!=EOF && n)
{
for(i=;i<n;i++)
scanf("%lf%lf%lf",&p[i].x,&p[i].y,&p[i].r);
int S = *;
double Si = 24.0*60.0;
int Plane;
double maxi = 0.0;
for(i=;i<S;i++)
{
if(i ==  || i ==  || i ==  || i == )
continue;
double A = tan(*pi*(double)i/Si);
double B = -1.0;
double k = A;
double di = sqrt(A*A+B*B);
if(i >  && i < )
Plane = ;
else if(i >  && i < )
Plane = ;
else if(i >  && i < )
Plane = ;
else
Plane = ;
double sum = 0.0;
for(j=;j<n;j++)
{
double x = p[j].x;
double y = p[j].y;
double r = p[j].r;
double PtoL = fabs(A*x-y)/di;
if(PtoL > r)
continue;
double AA = k*k+1.0;
double BB = -(2.0*x+2.0*k*y);
double CC = x*x + y*y - r*r;
if(BB*BB-4.0*AA*CC <= 0.0)
continue;
double jie1x = (-BB+sqrt(BB*BB-4.0*AA*CC))/(2.0*AA);
double jie1y = k*jie1x;
double jie2x = (-BB-sqrt(BB*BB-4.0*AA*CC))/(2.0*AA);
double jie2y = k*jie2x;
int P1 = getPlane(jie1x,jie1y);
int P2 = getPlane(jie2x,jie2y);
if(P1 == Plane && P2 == Plane)
sum += 2.0*sqrt(r*r-PtoL*PtoL);
else if(P1 == Plane)
sum += dis(jie1x,jie1y);
else if(P2 == Plane)
sum += dis(jie2x,jie2y);
}
maxi = max(maxi,sum);
}
//up
double sum = 0.0;
for(j=;j<n;j++)
{
double x = p[j].x;
double y = p[j].y;
double r = p[j].r;
double PtoL = x;
if(PtoL > r)
continue;
double AA = 1.0;
double BB = -2.0*y;
double CC = x*x + y*y - r*r;
double jie1x = 0.0;
double jie1y = (-BB+sqrt(BB*BB-4.0*AA*CC))/(2.0*AA);
double jie2x = 0.0;
double jie2y = (-BB-sqrt(BB*BB-4.0*AA*CC))/(2.0*AA);
if(jie1y >  && jie2y > )
sum += fabs(jie1y-jie2y);
else if(jie1y > )
sum += jie1y;
else if(jie2y > )
sum += jie2y;
}
maxi = max(maxi,sum);
//down
sum = 0.0;
for(j=;j<n;j++)
{
double x = p[j].x;
double y = p[j].y;
double r = p[j].r;
double PtoL = x;
if(PtoL > r)
continue;
double AA = 1.0;
double BB = -2.0*y;
double CC = x*x + y*y - r*r;
double jie1x = 0.0;
double jie1y = (-BB+sqrt(BB*BB-4.0*AA*CC))/(2.0*AA);
double jie2x = 0.0;
double jie2y = (-BB-sqrt(BB*BB-4.0*AA*CC))/(2.0*AA);
if(jie1y <  && jie2y < )
sum += fabs(jie1y-jie2y);
else if(jie1y < )
sum += -jie1y;
else if(jie2y < )
sum += -jie2y;
}
maxi = max(maxi,sum);
//right
sum = 0.0;
for(j=;j<n;j++)
{
double x = p[j].x;
double y = p[j].y;
double r = p[j].r;
double PtoL = y;
if(PtoL > r)
continue;
double AA = 1.0;
double BB = -2.0*x;
double CC = x*x + y*y - r*r;
double jie1x = (-BB+sqrt(BB*BB-4.0*AA*CC))/(2.0*AA);
double jie1y = 0.0;
double jie2x = (-BB-sqrt(BB*BB-4.0*AA*CC))/(2.0*AA);
double jie2y = 0.0;
if(jie1x >  && jie2x > )
sum += fabs(jie1x-jie2x);
else if(jie1x > )
sum += jie1x;
else if(jie2x > )
sum += jie2x;
}
maxi = max(maxi,sum);
//left
sum = 0.0;
for(j=;j<n;j++)
{
double x = p[j].x;
double y = p[j].y;
double r = p[j].r;
double PtoL = y;
if(PtoL > r)
continue;
double AA = 1.0;
double BB = -2.0*x;
double CC = x*x + y*y - r*r;
double jie1x = (-BB+sqrt(BB*BB-4.0*AA*CC))/(2.0*AA);
double jie1y = 0.0;
double jie2x = (-BB-sqrt(BB*BB-4.0*AA*CC))/(2.0*AA);
double jie2y = 0.0;
if(jie1x <  && jie2x < )
sum += fabs(jie1x-jie2x);
else if(jie1x < )
sum += -jie1x;
else if(jie2x < )
sum += -jie2x;
}
maxi = max(maxi,sum);
printf("%.3lf\n",maxi);
}
return ;
}```

## UVALive 6092 Catching Shade in Flatland --枚举+几何计算的更多相关文章

1. UVALive - 3263 That Nice Euler Circuit （几何）

UVALive - 3263 That Nice Euler Circuit (几何) ACM 题目地址:  UVALive - 3263 That Nice Euler Circuit 题意:  给 ...

2. 1549: Navigition Problem （几何计算+模拟 细节较多）

1549: Navigition Problem Submit Page    Summary    Time Limit: 1 Sec     Memory Limit: 256 Mb     Su ...

3. Jack Straws POJ - 1127 （几何计算）

Jack Straws Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 5428   Accepted: 2461 Descr ...

4. UVALive 6885 Flowery Trails 最短路枚举

题目连接: http://acm.hust.edu.cn/vjudge/problem/visitOriginUrl.action?id=129723 题意: 给你一个n点m图的边 1到n有多条最短路 ...

5. fzu 2035 Axial symmetry(枚举+几何）

题目链接:fzu 2035 Axial symmetry 题目大意:给出n个点,表示n边形的n个顶点,判断该n边形是否为轴对称图形.(给出点按照图形的顺时针或逆时针给出. 解题思路:将相邻两个点的中点 ...

6. UVALive 6692 Lucky Number （思路 + 枚举）

题意:给你n 个数字,某一个数的幸运数是这个数前面比他小 离他最远的位置之差,求出最大幸运值. 析:先按从大到小排序,然后去维护那个最大的id,一直比较,更新最大值就好. 代码如下: #pragma ...

7. Direct2D 几何计算和几何变幻

D2D不仅可以绘制,还可以对多个几何图形对象进行空间运算.这功能应该在GIS界比较吃香. 这些计算包括: 合并几何对象,可以设置求交还是求并,CombineWithGeometry 边界,加宽边界,查 ...

8. Codeforces 552E Vanya and Brackets（枚举 + 表达式计算）

题目链接 Vanya and Brackets 题目大意是给出一个只由1-9的数.乘号和加号组成的表达式,若要在这个表达式中加上一对括号,求加上括号的表达式的最大值. 我们发现,左括号的位置肯定是最左 ...

9. Jack Straws POJ - 1127 (简单几何计算 + 并查集）

In the game of Jack Straws, a number of plastic or wooden "straws" are dumped on the table ...

## 随机推荐

1. filesort是通过相应的排序算法

filesort是通过相应的排序算法,将取得的数据在max_length_for_sort_data的默认值是1024. --------------------------------------- ...

2. CSS3-canvas绘制线性渐变

3. C++ list&lt;list&lt;int&gt; &gt;类型的对象遍历

void listSort(list<list<int> >* initList) { list<list<int> >::iterator itera ...

4. POJ 1322 Chocolate（母函数）

题目链接:http://poj.org/problem?id=1322 题意: 思路: double C[N][N]; void init() { C[0][0]=1; int i,j; for(i= ...

5. &lt;测试用例设计&gt;用户及权限管理功能常规测试方法

1)  赋予一个人员相应的权限后,在界面上看此人员是否具有此权限,并以此人员身份登陆,验证权限设置是否正确(能否超出所给予的权限): 2)  删除或修改已经登陆系统并正在进行操作的人员的权限,程序能否 ...

6. hdu 4606 简单计算几何+floyd+最小路径覆盖

思路:将所有的直线的两个端点和城市混在一起,将能直接到达的两个点连线,求一次floyd最短路径.二分枚举bag容量,然后按给的要先后占领的城市由前向后,把能到一步到达的建一条边.然后求一次最小路径覆盖 ...

7. xcode 5与ios 7的屏幕适配问题

#define DEVICE_IS_IPHONE5 ([[UIScreen mainScreen] bounds].size.height == 568) float height = DEVICE_ ...

8. oracle多种导入导出数据方法

dmp格式: 1.dmp格式的导出可以通过客户端工具(PL/SQL)操作来完成,通过菜单栏---->Tools---->Export Tables,然后设置勾选相应参数即可,rows代表是 ...

9. 7 Serial Configuration 理解（三）

*Dynamic Reconfiguration Port(DRP) 动态重配置端口:在7系列FPGA中,配置存储器主要用于实现用户逻辑,连接和I / O,但它也用于其他目的. 例如,它用于指定功能块 ...

10. DevExpress控件cxGrid实现多列模糊匹配输入的完美解决方案

本方案不需要修改控件源码,是完美解决cxgrid或TcxDBExtLookupComboBox支持多列模糊匹配快速输入的最佳方案!! 转自https://blog.csdn.net/qq5643020 ...