题目链接

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. PHPCMS 实现上一篇下一篇的几种方法

    1第一种 <p>上一篇:{get sql = "select contentid,catid,url,titlee from phpcms_content where conte ...

  2. 微软改名部再次大显神威——ASP.NET 5改名ASP.NET Core 1.0

    (此文章同时发表在本人微信公众号"dotNET每日精华文章",欢迎右边二维码来关注.) 题记:在计算机科学领域只有两件难事:缓存不可用和命名.--Phil Karlton 今天,S ...

  3. C和C++混合编程(__cplusplus 与 external "c" 的使用)

    转自:http://blog.csdn.net/ljfth/article/details/3965871 第一种理解比如说你用C++开发了一个DLL库,为了能够让C语言也能够调用你的DLL输出(Ex ...

  4. Activity生命周期 onCreate onResume onStop onPause (转)

    Android应用开发提高系列(6)——Activity生命周期 onCreate 和 onResume 在程序启动时候都会启动, 所有有些需要在onCreate onResume中都要实现的功能,之 ...

  5. SSH 小总

    SSH 为 struts+spring+hibernate的一个集成框架,是目前较流行的一种Web应用程序开源框架. 集成SSH框架的系统从职责上分为四层:表示层.业务逻辑层.数据持久层和域模块层,以 ...

  6. 【J2EE入门】13个规范

    看过了j2ee教学视频,真的让我痛彻心扉,那叫痛并快乐着,痛是因为看了这么长时间,自己只知道了13个规范的概念:同样,快乐也正是因为我知道了13个规范的概念,接下来就是逐项实践的学习. 看了教学视频, ...

  7. matlab报错

    这可能说明..压根就没有这个函数

  8. sql 根据指定条件获取一个字段批量获取数据插入另外一张表字段中+MD5加密

    /****** Object: StoredProcedure [dbo].[getSplitValue] Script Date: 03/13/2014 13:58:12 ******/ SET A ...

  9. 【转】Kylin实践之使用Hive视图

    http://blog.csdn.net/yu616568/article/details/50548967 为什么需要使用视图 Kylin在使用的过程中使用hive作为cube的输入,但是有些情况下 ...

  10. AndroidTips:selector的disable状态为什么无效?

    正确的姿势: <?xml version="1.0" encoding="utf-8"?> <selector xmlns:android=& ...