题目链接

2Y,模版抄错了一点。

 #include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;
#define eps 1e-8
#define N 2001
struct point
{
double x,y;
}p[N],pre[N],temp[N];
double a,b,c;
int n,m;
void getline(point x,point y)
{
a = y.y - x.y;
b = x.x - y.x;
c = y.x * x.y - x.x * y.y;
}
point intersect(point x,point y)
{
double u = fabs(a*x.x + b*x.y + c);
double v = fabs(a*y.x + b*y.y + c);
point ans;
ans.x = (x.x*v+y.x*u)/(u+v);
ans.y = (x.y*v+y.y*u)/(u+v);
return ans;
}
void cut()
{
int num = ,i;
for(i = ;i <= m;i ++)
{
if(a*p[i].x + b*p[i].y + c > -eps)
{
temp[++num] = p[i];
}
else
{
if(a*p[i-].x + b*p[i-].y + c > eps)
temp[++num] = intersect(p[i],p[i-]);
if(a*p[i+].x + b*p[i+].y + c > eps)
temp[++num] = intersect(p[i],p[i+]);
}
}
for(i = ;i <= num;i ++)
p[i] = temp[i];
p[] = p[num];
p[num+] = p[];
m = num;
}
void fun()
{
int i;
m = n;
for(i = ;i <= n;i ++)
{
getline(pre[i],pre[i+]);
cut();
}
}
int main()
{
int i,cas = ;
while(scanf("%d",&n)!=EOF)
{
if(!n) break;
for(i = ;i <= n;i ++)
{
scanf("%lf%lf",&pre[i].x,&pre[i].y);
p[i] = pre[i];
}
pre[n+] = pre[];
p[n+] = p[];
p[] = p[n];
fun();
printf("Floor #%d\n",cas ++);
if(m)
printf("Surveillance is possible.\n");
else
printf("Surveillance is impossible.\n");
printf("\n");
}
return ;
}

POJ 1474 Video Surveillance(半平面交)的更多相关文章

  1. POJ 1474 Video Surveillance 半平面交/多边形核是否存在

    http://poj.org/problem?id=1474 解法同POJ 1279 A一送一 缺点是还是O(n^2) ...nlogn的过几天补上... /********************* ...

  2. poj 1474 Video Surveillance - 求多边形有没有核

    /* poj 1474 Video Surveillance - 求多边形有没有核 */ #include <stdio.h> #include<math.h> const d ...

  3. poj 1474 Video Surveillance (半平面交)

    链接:http://poj.org/problem?id=1474 Video Surveillance Time Limit: 1000MS   Memory Limit: 10000K Total ...

  4. poj 1474 Video Surveillance 【半平面交】

    半平面交求多边形的核,注意边是顺时针给出的 //卡精致死于是换(?)了一种求半平面交的方法-- #include<iostream> #include<cstdio> #inc ...

  5. ●poj 1474 Video Surveillance

    题链: http://poj.org/problem?id=1474 题解: 计算几何,半平面交 半平面交裸题,快要恶心死我啦... (了无数次之后,一怒之下把onleft改为onright,然后还加 ...

  6. POJ1474 Video Surveillance(半平面交)

    求多边形核的存在性,过了这题但是过不了另一题的,不知道是模板的问题还是什么,但是这个模板还是可以过绝大部分的题的... #pragma warning(disable:4996) #include & ...

  7. poj1474Video Surveillance(半平面交)

    链接 半平面交的模板题,判断有没有核.: 注意一下最后的核可能为一条线,面积也是为0的,但却是有的. #include<iostream> #include <stdio.h> ...

  8. 2018.07.03 POJ 1279Art Gallery(半平面交)

    Art Gallery Time Limit: 1000MS Memory Limit: 10000K Description The art galleries of the new and ver ...

  9. POJ 3335 Rotating Scoreboard 半平面交求核

    LINK 题意:给出一个多边形,求是否存在核. 思路:比较裸的题,要注意的是求系数和交点时的x和y坐标不要搞混...判断核的顶点数是否大于1就行了 /** @Date : 2017-07-20 19: ...

随机推荐

  1. .net学习之进程外Session的配置

    转载地址:http://www.cnblogs.com/rohelm/archive/2012/05/13/2498465.html 人人都知道怎么去使用session,但是初学者,尤其是自学的学生可 ...

  2. C# 创建Windows Service

    当我们需要一个程序长期运行,但是不需要界面显示时可以考虑使用Windows Service来实现.这篇博客将简单介绍一下如何创建一个Windows Service,安装/卸载Windows Servi ...

  3. hdu 4389 数位dp

    求区间内满足x%fx==0的数的个数,fx为该数各个位数上的数字之和Sample Input21 1011 20 Sample OutputCase 1: 10Case 2: 3 大小不是你想开,想开 ...

  4. [Java] xms xmx XX:PermSize XX:MaxPermSize 参数意义解析

    今天在做jmeter压力测试时又出现以前经常出现的异常,如下图,长时间不弄这个的,又有点不知所措了,所以干脆再来总结一下问题: 以前写过两篇文章,对这个问题研究过,见下面连接: 连接1:http:// ...

  5. PMP 第二章 项目生命周期与组织

    1 项目组织机构类型有哪些? 区别是什么? 职能型  矩阵型  项目性 2 什么是事业环境因素? 什么是组织过程资产? 如何区分事业环境因素和组织过程资产? 事业环境因素:事业环境因素指围绕项目或能影 ...

  6. Ubuntu14.04LTS系统QQ的安装:pidgin-lwqq

    本人是轻度聊天工具使用者(大言不惭是轻度,偷笑),发现输入法到博主也有解决linux下QQ的解决方法,一并抄过来,有需要,请联系原作者 参考链接:http://www.cnblogs.com/zhj5 ...

  7. 关于三星I9305出现android.process.acore提示问题

    背景:自己用百度云同步通讯录和用微信电话本删除联系人的时候总出现提示acore问题,为此上网找了许久. 网络上多说解决方案为:把Calendar.apk和CalendarProvider.apk两个文 ...

  8. 用PowerShell脚本实现对SharePoint页面Title的修改

    存在这样一种情况,对应的page已经部署到product的SharePoint环境中,那么在部署下一个版本的时候就不允许把已经创建好的page删除再创建,因此page中修改过的属性就不能再次部署到Sh ...

  9. HDU 4005 The war Tarjan+dp

    The war Problem Description   In the war, the intelligence about the enemy is very important. Now, o ...

  10. BZOJ 1861: [Zjoi2006]Book 书架 splay

    1861: [Zjoi2006]Book 书架 Description 小T有一个很大的书柜.这个书柜的构造有些独特,即书柜里的书是从上至下堆放成一列.她用1到n的正整数给每本书都编了号. 小T在看书 ...