列出不等式后,把同时除Z把它去掉。

注意了,这里应该 是把直线变两点表示的向量更为简单,我开始就直接用直线写,后来,唉,写不下去了。。

#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cmath>
using namespace std;
const int MAX=110;
const double eps=1e-10;
const double inf=1e10; struct point{
double x,y;
};
point operator -(point x,point y){
point t;
t.x=x.x-y.x; t.y=x.y-y.y;
return t;
} double operator *(point x,point y){
return x.x*y.y-x.y*y.x;
} struct line{
point a,b;
double angle;
};
int n,lnum;
double A[MAX],B[MAX],C[MAX];
line le[MAX],st[MAX]; int DB(double d){
if(fabs(d)<eps) return 0;
if(d>0) return 1;
return -1;
} void addLine(double x1,double y1,double x2,double y2){
point a; a.x=x1; a.y=y1;
point b; b.x=x2; b.y=y2;
le[lnum].a=a; le[lnum].b=b;
le[lnum].angle=atan2(y2-y1,x2-x1);
} bool cmp( line x, line y){
if(fabs(x.angle-y.angle)<eps){
if((y.b-x.a)*(x.b-y.a)>eps)
return true;
return false;
}
return x.angle<y.angle;
} void getIntersect(line l1, line l2, point& p) {
double dot1,dot2;
dot1 = (l1.b-l2.a)*(l1.a-l2.a);
dot2 = (l2.b-l1.b)*( l1.a-l1.b);
p.x = (l2.a.x * dot2 + l2.b.x * dot1) / (dot2 + dot1);
p.y = (l2.a.y * dot2 + l2.b.y * dot1) / (dot2 + dot1);
} bool judge(line l0, line l1, line l2) {
point p;
getIntersect(l1, l2, p);
return DB((l0.a-p)*(l0.b-p)) <=0;
} bool pare(line x,line y){
return fabs((x.b-x.a)*(y.b-y.a))<eps;
} bool half(){
int top=1,bot=0;
sort(le,le+lnum,cmp);
int tmp=1;
for(int i=1;i<lnum;i++){
if(fabs(le[i].angle-le[tmp-1].angle)>eps) le[tmp++]=le[i];
}
lnum=tmp;
st[0]=le[0]; st[1]=le[1];
for(int i=2;i<lnum;i++){
while(bot<top&&judge(le[i], st[top-1], st[top])) top--;
while(bot<top&&judge(le[i],st[bot+1],st[bot])) bot++;
st[++top]=le[i];
}
while(bot<top&&judge(st[bot],st[top-1],st[top])) top--;
while(bot<top&&judge(st[top],st[bot+1],st[bot])) bot++;
if(top<=bot+1) return false;
return true;
} bool slove(int s){
int i, j, k;
double x1, y1, x2, y2, a, b, c;
lnum=0;
addLine(0, 0, inf, 0 ); lnum++;
addLine(inf, 0, inf, inf ); lnum++;
addLine(inf, inf, 0, inf ); lnum++;
addLine(0, inf, 0, 0 ); lnum++;
for (j = 0; j < n; j++)
if (s != j) {
a = 1.0 / A[j] - 1.0 / A[s];
b = 1.0 / B[j] - 1.0 / B[s];
c = 1.0 / C[j] - 1.0 / C[s];
int d1 = DB(a);
int d2 = DB(b);
int d3 = DB(c);
if (!d1) {
if (!d2) {
if (d3 <= 0) {
return false;
}
continue;
}
x1 = 0;
x2 = d2;
y1 = y2 = - c / b;
}
else {
if (!d2) {
x1 = x2 = - c / a;
y1 = 0;
y2 = -d1;
}
else {
x1 = 0; y1 = - c / b;
x2 = d2;
y2 = -(c + a * x2) / b;
}
}
addLine(x1, y1, x2, y2 );
lnum++;
}
if(!half()) return false;
return true;
} int main(){
while(scanf("%d",&n)!=EOF){
for(int i=0;i<n;i++)
scanf("%lf%lf%lf",&A[i],&B[i],&C[i]);
for(int i=0;i<n;i++){
if(slove(i)) printf("Yes\n");
else printf("No\n");
}
}
return 0;
}

  

POJ 1755的更多相关文章

  1. poj 1755 半平面交+不等式

    Triathlon Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 6461   Accepted: 1643 Descrip ...

  2. POJ 1755 Triathlon

    http://poj.org/problem?id=1755 题意:铁人三项,每个人有自己在每一段的速度,求有没有一种3条路线长度都不为0的设计使得某个人能严格获胜? 我们枚举每个人获胜,得到不等式组 ...

  3. POJ 1755 Triathlon [半平面交 线性规划]

    Triathlon Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 6912   Accepted: 1790 Descrip ...

  4. POJ 1755 Triathlon 半平面交

    看的这里:http://blog.csdn.net/non_cease/article/details/7820361 题意:铁人三项比赛,给出n个人进行每一项的速度vi, ui, wi;  对每个人 ...

  5. POJ 1755 Triathlon (半平面交)

    Triathlon Time Limit: 1000MS   Memory Limit: 10000K Total Submissions: 4733   Accepted: 1166 Descrip ...

  6. POJ 1755 Triathlon(线性规划の半平面交)

    Description Triathlon is an athletic contest consisting of three consecutive sections that should be ...

  7. [转] POJ计算几何

    转自:http://blog.csdn.net/tyger/article/details/4480029 计算几何题的特点与做题要领:1.大部分不会很难,少部分题目思路很巧妙2.做计算几何题目,模板 ...

  8. 【BZOJ】【2765】【JLOI2010】铁人双项比赛

    计算几何/半平面交 本来我是想去写POJ 1755的,然后想起了这道跟它很像的题,但应该是弱化版,所以就先写了这个…… 我们可以发现每个人的总用时,与k是呈一次函数关系的:$time_i=\frac{ ...

  9. ACM计算几何题目推荐

    //第一期 计算几何题的特点与做题要领: 1.大部分不会很难,少部分题目思路很巧妙 2.做计算几何题目,模板很重要,模板必须高度可靠. 3.要注意代码的组织,因为计算几何的题目很容易上两百行代码,里面 ...

随机推荐

  1. bzoj4977 跳伞求生——贪心

    题目:https://www.lydsy.com/JudgeOnline/problem.php?id=4977 今天讲的贪心题,真神奇啊: 首先,要得到尽量多选队友的解: 把队友按 a[i] 从小到 ...

  2. 89. Ext.Button 按钮

    转自:http://www.cnblogs.com/lipan/archive/2011/12/13/2274797.html 从本篇开始讲基础控件,ExtJs对所有的UI控件都有它自己的一套封装.本 ...

  3. django自带url模板标签的使用

    django模板中url标签和view中的reverse(博客地址)功能相同,都是通过制定处理视图来返回一个url. 使用方法: {% url userEdit 12 %} 或者 {% url use ...

  4. python对XML 操作

    一.XML的读取. 在 NewEdit 中有代码片段的功能,代码片段分为片段的分类和片段的内容.在缺省情况下都是用XML格式保存的.下面我讲述一下,如何使用minidom来读取和保存XML文件. 下面 ...

  5. Python 34(进程了解)

    一:僵尸进程与孤儿进程 测试程序: 基本概念: 一个进程使用fork创建子进程,如果子进程退出,而父进程并没有调用wait或waitpid获取子进程的状态信息,那么子进程的进程描述符仍然保存在系统中. ...

  6. 如何在linux下搭建svn服务

    • 安装svn 使用命令 yum install subversion 如果提示上述错误,请以管理员身份运行 使用命令su root 再执行 yum install subversion 2,查看sv ...

  7. C#之MD5加密

    C#实现MD5加密 方法一 首先,先简单介绍一下MD5 MD5的全称是message-digest algorithm 5(信息-摘要算法,在90年代初由mit laboratory for comp ...

  8. UML基本关系

    UML-Unified Model Language 统一建模语言,又称标准建模语言.是用来对软件密集系统进行可视化建模的一种语言.UML的定义包括UML语义和UML表示法两个元素. UML是在开发阶 ...

  9. CSS选择器优先级计算

    优先级从高到低排列,浏览器优先满足前面的规则 1,!important优先级最高 2,内联样式 3,作者>读者>浏览器 4,优先级权重加法 id选择器+100/个 类/伪类选择器+10/个 ...

  10. 关于Core里的 StartUp里的方法的理解。

    public class Startup { public Startup(IConfiguration configuration) { Configuration = configuration; ...