题意:给定几个圆,求最短的围合,把这几个包围起来,而且到圆的距离都不小于10.

思路:把每个圆的半径+10,边等分5000份,然后求凸包即可。

#include<bits/stdc++.h>
using namespace std;
#define mp make_pair
typedef long long ll;
const double inf=1e200;
const double eps=1e-;
const double pi=*atan(1.0);
int dcmp(double x){ return fabs(x)<eps?:(x<?-:);}
struct point{
double x,y;
point(double a=,double b=):x(a),y(b){}
};
point operator +(point A,point B) { return point(A.x+B.x,A.y+B.y);}
point operator -(point A,point B) { return point(A.x-B.x,A.y-B.y);}
point operator *(point A,double p){ return point(A.x*p,A.y*p);}
point operator /(point A,double p){ return point(A.x/p,A.y/p);}
point rotate(point A,double rad){
return point(A.x*cos(rad)-A.y*sin(rad),A.x*sin(rad)+A.y*cos(rad));
}
bool operator ==(const point& a,const point& b) {
return dcmp(a.x-b.x)==&&dcmp(a.y-b.y)==;
}
double dot(point A,point B){ return A.x*B.x+A.y*B.y;}
double det(point A,point B){ return A.x*B.y-A.y*B.x;}
double det(point O,point A,point B){ return det(A-O,B-O);}
double length(point A){ return sqrt(dot(A,A));}
double angle(point A,point B){ return acos(dot(A,B)/length(A)/length(B));}
double area(vector<point>p){
double ans=; int sz=p.size();
for(int i=;i<sz-;i++) ans+=det(p[i]-p[],p[i+]-p[]);
return ans/2.0;
}
double seg(point O,point A,point B){
if(dcmp(B.x-A.x)==) return (O.y-A.y)/(B.y-A.y);
return (O.x-A.x)/(B.x-A.x);
} pair<double,int>s[*];
double polyunion(vector<point>*p,int N){ //有多个才加*
double res=;
for(int i=;i<N;i++){
int sz=p[i].size();
for(int j=;j<sz;j++){
int m=;
s[++m]=mp(,);
s[++m]=mp(,);
point a=p[i][j],b=p[i][(j+)%sz];
for(int k=;k<N;k++){
if(i!=k){
int sz2=p[k].size();
for(int ii=;ii<sz2;ii++){
point c=p[k][ii],d=p[k][(ii+)%sz2];
int c1=dcmp(det(b-a,c-a));
int c2=dcmp(det(b-a,d-a));
if(c1==&&c2==){
if(dcmp(dot(b-a,d-c))){
s[++m]=mp(seg(c,a,b),);
s[++m]=mp(seg(c,a,b),-);
}
}
else{
double s1=det(d-c,a-c);
double s2=det(d-c,b-c);
if(c1>=&&c2<) s[++m]=mp(s1/(s1-s2),);
else if(c1<&&c2>=) s[++m]=mp(s1/(s1-s2),-);
}
}
}
}
sort(s+,s+m+);
double pre=min(max(s[].first,0.0),1.0),now,sum=;
int cov=s[].second;
for(int j=;j<=m;j++){
now=min(max(s[j].first,0.0),1.0);
if(!cov) sum+=now-pre;
cov+=s[j].second;
pre=now;
}
res+=det(a,b)*sum;
}
}
return res/;
}
bool cmp(point a,point b){ return a.x==b.x?a.y<b.y:a.x<b.x; }
void convexhull(point *a,int n,point *ch,int &top)
{
sort(a+,a+n+,cmp);
top=;
for(int i=;i<=n;i++){
while(top>=&&det(ch[top-],ch[top],a[i])<=) top--;
ch[++top]=a[i];
}
int ttop=top;
for(int i=n-;i>=;i--){
while(top>ttop&&det(ch[top-],ch[top],a[i])<=) top--;
ch[++top]=a[i];
}
}
point ch[],p[]; vector<point>pp[];
int main()
{
int N,i,j,tot=,top; double ans,one=pi/,x,y,r;
scanf("%d",&N);
for(i=;i<=N;i++){
scanf("%lf%lf%lf",&x,&y,&r); r+=;
for(j=;j<=;j++){
tot++; p[tot].x=x+r*cos(one*j); p[tot].y=y+r*sin(one*j);
}
}
convexhull(p,tot,ch,top);
for(i=;i<top;i++) ans+=length(ch[i]-ch[i+]);
printf("%.10lf\n",ans);
return ;
}

Gym - 101673:B Craters (几何,求凸包)的更多相关文章

  1. 简单几何(求凸包点数) POJ 1228 Grandpa's Estate

    题目传送门 题意:判断一些点的凸包能否唯一确定 分析:如果凸包边上没有其他点,那么边想象成橡皮筋,可以往外拖动,这不是唯一确定的.还有求凸包的点数<=2的情况一定不能确定. /********* ...

  2. Graham扫描法 --求凸包

    前言: 首先,什么是凸包? 假设平面上有p0~p12共13个点,过某些点作一个多边形,使这个多边形能把所有点都“包”起来.当这个多边形是凸多边形的时候,我们就叫它“凸包”.如下图:  然后,什么是凸包 ...

  3. HDU 1392 凸包模板题,求凸包周长

    1.HDU 1392 Surround the Trees 2.题意:就是求凸包周长 3.总结:第一次做计算几何,没办法,还是看了大牛的博客 #include<iostream> #inc ...

  4. Wall--POJ1113(极角排序+求凸包)

    http://poj.org/problem?id=1113 题目大意:现在要给n个点,让你修一个围墙把这些点围起来,距离最小是l 分析  :现在就是求凸包的周长然后再加上一个圆的周长 #includ ...

  5. 计算几何--求凸包模板--Graham算法--poj 1113

    Wall Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 28157   Accepted: 9401 Description ...

  6. poj 1113:Wall(计算几何,求凸包周长)

    Wall Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 28462   Accepted: 9498 Description ...

  7. 简单几何(数学公式+凸包) UVA 11168 Airport

    题目传送门 题意:找一条直线,使得其余的点都在直线的同一侧,而且使得到直线的平均距离最短. 分析:训练指南P274,先求凸包,如果每条边都算一边的话,是O (n ^ 2),然而根据公式知直线一般式为A ...

  8. Wall---hdu1348(求凸包周长 模板)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1348 求凸包周长+2*PI*L: #include <stdio.h> #include ...

  9. POJ 1113 Wall(Graham求凸包周长)

    题目链接 题意 : 求凸包周长+一个完整的圆周长. 因为走一圈,经过拐点时,所形成的扇形的内角和是360度,故一个完整的圆. 思路 : 求出凸包来,然后加上圆的周长 #include <stdi ...

随机推荐

  1. nightwatch 切换窗口

    .switchWindow() Change focus to another window. The window to change focus to may be specified by it ...

  2. XTUOJ 1176 I Love Military Chess(模拟)

     I Love Military Chess Accepted : 45   Submit : 141 Time Limit : 1000 MS   Memory Limit : 65536 KB ...

  3. 输入两手牌,两手牌之间用“-”连接,每手牌的每张牌以空格分隔,“-”两边没有空格,如:4 4 4 4-joker JOKER 请比较两手牌大小,输出较大的牌,如果不存在比较关系则输出ERROR

    // ConsoleApplication10.cpp : 定义控制台应用程序的入口点. // #include "stdafx.h" #include <iostream& ...

  4. C# 杀掉后台进程

    var p = Process.GetProcessesByName("WINWORD"); if (p.Any()) { for (int i = 0; i < p.Len ...

  5. dnSpy进行反编译修改并编译运行EXE或DLL

    dnSpy对目标程序(EXE或DLL)进行反编译修改并编译运行 本文为原创文章.源代码为原创代码,如转载/复制,请在网页/代码处明显位置标明原文名称.作者及网址,谢谢! 本文使用的工具下载地址为: h ...

  6. 初识vue-01

    一.属性和方法 vue自定义的一些数据和方法需要绑定到实例的不同属性上面去例如数据都要绑定要data属性,方法都要绑定到methods方法实例上的data和methods里面的key值会自动挂载到vu ...

  7. 【剑指Offer学习】【面试题58:二叉树的下一个结点】

    题目:给定一棵二叉树和当中的一个结点.怎样找出中序遍历顺序的下一个结点?树中的结点除了有两个分别指向左右子结点的指针以外,另一个指向父节点的指针. 解题思路 假设一个结点有右子树.那么它的下一个结点就 ...

  8. Android Apk包下查看 sha1

    用keytool工具查看sha1,格式如下:keytool -printcert -file  Urovo.RSA文件路径(APK解压后在Meta-INF文件夹下)

  9. Java知识点梳理——常用方法总结

    1.查找字符串最后一次出现的位置 String str = "my name is zzw"; int lastIndex = str.lastIndexOf("zzw& ...

  10. bootstrap中模态框的大小设置;

    bootstrap模态框调节大小: 大尺寸:黑体加大的字体,是更改的代码 <!-- 大模态框的调节 --> <button type="button" class ...