列出不等式后,把同时除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. JS文件中的中文在网页上显示为乱码解决方法

    转自:http://www.pc6.com/infoview/Article_63835.html 如果JS文件中的中文在网页上显示为乱码,不妨采用本文章中的方法来试一试,或许能解决使你很头疼的问题. ...

  2. springboot踩坑出坑记

    4月15到4月17我都在把毕设从eclipse重构到IDEA中,springboot最让我头疼的是它的版本问题,因为每一个版本对应的依赖包都有可能出错,这里分享一下如何成功移植用eclipse写的sp ...

  3. flume+flume+kafka消息传递+storm消费

    通过flume收集其他机器上flume的监测数据,发送到本机的kafka进行消费. 环境:slave中安装flume,master中安装flume+kafka(这里用两台虚拟机,也可以用三台以上) m ...

  4. mybatis一对多关系的关联查询

    问题描述:实现两张表的关联查询 学生表: 班级表: 要实现学生管理信息中有所在班级的名称,即如下图所示 1.对应学生表的pojo类写全班级表中的字段(适用于要连接的表字段较少的情况) sql语句直接在 ...

  5. Win7的虚拟Wi-Fi

    前几天无意中发现,Win7的硬件驱动里有个叫Microsoft Virtual WiFi Miniport Adapter的东东,从网上查了一下,可以用来组建临时网络,共享Internet.一块无线网 ...

  6. C#之单列双列集合绑定数据

    ---恢复内容开始--- 1.单列集合绑定方式 davList.DataSource=new BindingList<类型名>(集合名); 2.双列集合绑定方式 BindingSource ...

  7. JavaScript Array 整理 - 元素操作

    整理一下Array对象中针对元素操作的方法. 分别是: concat (组合数组) join(数组转字符串) pop(删除最后一个元素) shift(删除第一个元素) push(在数组尾部添加新元素) ...

  8. C# 禁止WebBrowser网页跳转时发出的声音

    ; const int SET_FEATURE_ON_PROCESS = 0x00000002; [DllImport("urlmon.dll")] [PreserveSig] [ ...

  9. 连接Oracle数据库帮助类

    连接Oracle数据库帮助类,就是把连接Oracle数据库的方法封装起来,只需要在其它页面调用就可,不需要重复写. import java.sql.Connection; import java.sq ...

  10. Java基础学习笔记: 多线程,线程池,同步锁(Lock,synchronized )(Thread类,ExecutorService ,Future类)(卖火车票案例)

    多线程介绍 学习多线程之前,我们先要了解几个关于多线程有关的概念.进程:进程指正在运行的程序.确切的来说,当一个程序进入内存运行,即变成一个进程,进程是处于运行过程中的程序,并且具有一定独立功能. 线 ...