思路:

小圆面是由小圆弧围成。那么找出每条小圆弧,如果小圆弧,在小圆弧中点上下左右进行微小位移的所得的点一定在一个小圆面内。

找到最后覆盖这个小点的圆一定是可见的。

圆上的点按照相邻依次排序的关键量为极角(0,2PI)

用中心点代替圆弧本身是否被圆覆盖

 #include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<memory.h>
#include<cstdlib>
#include<vector>
#define clc(a,b) memset(a,b,sizeof(a))
#define LL long long int
#define up(i,x,y) for(i=x;i<=y;i++)
#define w(a) while(a)
using namespace std;
const int inf=0x3f3f3f3f;
const int N = ;
const double eps = *1e-;
const double pi = acos(-); int dcmp(double x)
{
if(fabs(x) < eps) return ;
else return x < ? - : ;
} const double PI = acos(-);
const double TWO_PI = PI * ; double NormalizeAngle(double rad, double center = PI)
{
return rad - TWO_PI * floor((rad + PI - center) / TWO_PI);
} struct Point
{
double x, y;
Point(double x=, double y=):x(x),y(y) { }
}; typedef Point Vector; 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);
} 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 angle(Vector v)
{
return atan2(v.y, v.x);
} // 交点相对于圆1的极角保存在rad中
void getCircleCircleIntersection(Point c1, double r1, Point c2, double r2, vector<double>& rad)
{
double d = Length(c1 - c2);
if(dcmp(d) == ) return; // 不管是内含还是重合,都不相交
if(dcmp(r1 + r2 - d) < ) return;
if(dcmp(fabs(r1-r2) - d) > ) return; double a = angle(c2 - c1);
double da = acos((r1*r1 + d*d - r2*r2) / (*r1*d));
rad.push_back(NormalizeAngle(a-da));
rad.push_back(NormalizeAngle(a+da));
} const int maxn = + ;
int n;
Point center[maxn];
double radius[maxn];
bool vis[maxn]; // 覆盖点p的最上层的圆
int topmost(Point p)
{
for(int i = n-; i >= ; i--)
if(Length(center[i]-p) < radius[i]) return i;
return -;
} int main()
{
while(cin >> n)
{
if(!n) break;
for(int i = ; i < n; i++)
{
double x, y, r;
cin >> x >> y >> r;
center[i] = Point(x, y);
radius[i] = r;
}
memset(vis, , sizeof(vis));
for(int i = ; i < n; i++)
{
// 考虑圆i被切割成的各个圆弧。把圆周当做区间来处理,起点是0,终点是2PI
vector<double> rad;
rad.push_back();
rad.push_back(PI*);
for(int j = ; j < n; j++)
getCircleCircleIntersection(center[i], radius[i], center[j], radius[j], rad);
sort(rad.begin(), rad.end()); for(int j = ; j < rad.size(); j++)
{
double mid = (rad[j] + rad[j+]) / 2.0; // 圆弧中点相对于圆i圆心的极角
for(int side = -; side <= ; side += )
{
double r2 = radius[i] - side*eps; // 往里面或者外面稍微一动一点点
int t = topmost(Point(center[i].x + cos(mid)*r2, center[i].y + sin(mid)*r2));
if(t >= ) vis[t] = true;
}
}
}
int ans = ;
for(int i = ; i < n; i++) if(vis[i]) ans++;
cout << ans << "\n";
}
return ;
}

uva 2572 Viva Confetti的更多相关文章

  1. uva 1308 - Viva Confetti

    这个题目的方法是将圆盘分成一个个圆环,然后判断这些圆环是否被上面的圆覆盖: 如果这个圆的圆周上的圆弧都被上面的覆盖,暂时把它标记为不可见: 然后如果他的头上有个圆,他有个圆弧可见,那么他自己本身可见, ...

  2. poj1418 Viva Confetti 判断圆是否可见

    转载请注明出处: http://www.cnblogs.com/fraud/          ——by fraud Viva Confetti Time Limit: 1000MS   Memory ...

  3. poj 1418 Viva Confetti

    Viva Confetti Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 1025   Accepted: 422 Desc ...

  4. ZOJ 1696 Viva Confetti 计算几何

    计算几何:按顺序给n个圆覆盖.问最后能够有几个圆被看见.. . 对每一个圆求和其它圆的交点,每两个交点之间就是可能被看到的圆弧,取圆弧的中点,往外扩展一点或者往里缩一点,从上往下推断有没有圆能够盖住这 ...

  5. UVaLive2572 poj1418 UVa1308 Viva Confetti

    一次放下n个圆 问最终可见的圆的数量 应该是比较经典的问题吧 考虑一个圆与其他每个圆的交点O(n)个 将其割成了O(n)条弧 那么看每条弧的中点 分别向内向外调动eps这个点 则最上面的覆盖这个点的圆 ...

  6. LA2572 Viva Confetti

    题意 PDF 分析 两两圆求交点,对每个圆弧按半径抖动. 时间复杂度\(O(T n^2)\) 代码 #include<iostream> #include<cstdio> #i ...

  7. [GodLove]Wine93 Tarining Round #9

    比赛链接: http://vjudge.net/contest/view.action?cid=48069#overview 题目来源: lrj训练指南---二维几何计算   ID Title Pro ...

  8. POJ 1418 基本操作和圆 离散弧

    Viva Confetti Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 761   Accepted: 319 Descr ...

  9. UVa 10969 (圆与圆之间的覆盖问题) Sweet Dream

    题意: 有n个按先后顺序放置的不同大小不同位置的圆,求所有可见圆弧的长度. 分析: 这道题应该是大白书上例题 LA 2572 (求可见圆盘的数量) Kanazawa 的加强版,整体框架都差不多. 对于 ...

随机推荐

  1. 5.2:缓存中获取单例bean

    5.2  缓存中获取单例bean 介绍过FactoryBean的用法后,我们就可以了解bean加载的过程了.前面已经提到过,单例在Spring的同一个容器内只会被创建一次,后续再获取bean直接从单例 ...

  2. WEB开发者必备的7个JavaScript函数

    防止高频调用的debounce函数 这个 debounce 函数对于那些执行事件驱动的任务来说是必不可少的提高性能的函数.如果你在使用scroll, resize, key*等事件触发执行任务时不使用 ...

  3. Python 开源异步并发框架的未来

    http://segmentfault.com/a/1190000000471602 开源 Python 是开源的,介绍的这几个框架 Twisted.Tornado.Gevent 和 tulip 也都 ...

  4. hdu 1851 A Simple Game 博弈论

    简单博弈问题(巴什博弈-Bash Game) 巴什博弈:只有一堆n个物品,两个人轮流从这对物品中取物,规定每次至少取一个,最多取m个,最后取光着得胜. 很容易想到当n%(m+1)!=0时,先取者必胜, ...

  5. ANDROID_MARS学习笔记_S01_012_SeekBar

    1.xml <RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns: ...

  6. Android 使用SDcard进行文件的读取

    平时我们需要在手机上面存储想音频,视频等等的大文件,以前学过使用File进行存储(使用File操作进行存储):由于考虑到手机本身的存储空间小,这时候我们需要把文件存储在SDcard中,今天自己也学习了 ...

  7. perl next和last

    跳出控制结构:next和last next 和last 操作符运维你在循环中改变程序执行的方向,你可能经常会遇到一些的特殊情况, 碰到这种情况时你希望跳过它,或者像退出循环. 比如当你处理Unix 账 ...

  8. 3月下旬剩余poj题解

    poj1700 数学推导+简单dp poj2390 水题不说什么了 poj3260 先对找的钱做完全背包,在对能付的钱做多重背包,注意这道题能付的钱数的上界 poj2516 裸的最小费用最大流了没什么 ...

  9. UVa 10622 (gcd 分解质因数) Perfect P-th Powers

    题意: 对于32位有符号整数x,将其写成x = bp的形式,求p可能的最大值. 分析: 将x分解质因数,然后求所有指数的gcd即可. 对于负数还要再处理一下,负数求得的p必须是奇数才行. #inclu ...

  10. 纯干货,Spring-data-jpa详解,全方位介绍

    本篇进行Spring-data-jpa的介绍,几乎涵盖该框架的所有方面,在日常的开发当中,基本上能满足所有需求.这里不讲解JPA和Spring-data-jpa单独使用,所有的内容都是在和Spring ...