半平面交的题;

这个题目的亮点就是建模;

 #include<cstdio>
#include<algorithm>
#include<cmath>
#define maxn 109
#define eps 1e-6
using namespace std; int dcmp(double x)
{
return fabs(x) < eps ? : (x > ? : -);
} struct Point
{
double x;
double y;
Point(double x = , double y = ):x(x), y(y) {}
};
typedef Point Vector; Vector operator + (Point A, Point 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 * (Point A, double p)
{
return Vector(A.x * p, A.y * p);
} Vector operator / (Point A, double p)
{
return Vector(A.x / p, A.y / p);
}
double dot(Point a,Point b)
{
return a.x*b.x+a.y*b.y;
}
double cross(Point a,Point b)
{
return a.x*b.y-a.y*b.x;
} Vector nomal(Vector a)
{
double l=sqrt(dot(a,a));
return Vector(-a.y/l,a.x/l);
} struct line
{
Point p;
Vector v;
double ang;
line() {}
line(Point p,Vector v):p(p),v(v)
{
ang=atan2(v.y,v.x);
}
bool operator<(const line &t)const
{
return ang<t.ang;
}
}; bool onleft(line l,Point p)
{
return (cross(l.v,p-l.p)>);
} Point getintersection(line a,line b)
{
Vector u=a.p-b.p;
double t=cross(b.v,u)/cross(a.v,b.v);
return a.p+a.v*t;
} int halfplanintersection(line *l,int n,Point *poly)
{
sort(l,l+n);
int first,last;
Point *p=new Point[n];
line *q=new line[n];
q[first=last=]=l[];
for(int i=; i<n; i++)
{
while(first<last && !onleft(l[i],p[last-]))last--;
while(first<last && !onleft(l[i],p[first]))first++;
q[++last]=l[i];
if(fabs(cross(q[last].v,q[last-].v))<eps)
{
last--;
if(onleft(q[last],l[i].p))q[last]=l[i];
}
if(first<last)p[last-]=getintersection(q[last-],q[last]);
}
while(first<last && !onleft(q[first],p[last-]))last--;
if((last-first )<=)return ;
p[last]=getintersection(q[last],q[first]);
int m=;
for(int i=first; i<=last; i++)poly[m++]=p[i];
return m;
} Point poly[maxn];
line l[maxn];
double v[maxn],u[maxn],w[maxn]; int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
for(int i=;i<n;i++)scanf("%lf%lf%lf",&v[i],&u[i],&w[i]);
for(int i=;i<n;i++)
{
double k=;
bool flag=;
int cnt=;
for(int j=;j<n;j++)
{
if(i==j)continue;
if(v[j]>=v[i]&&u[j]>=u[i]&&w[j]>=w[i]){flag=;break;}
if(v[j]<=v[i]&&w[j]<=u[i]&&w[j]<=w[i])continue;
double a=(k/v[j]-k/w[j])-(k/v[i]-k/w[i]);
double b=(k/u[j]-k/w[j])-(k/u[i]-k/w[i]);
double c=k/w[j]-k/w[i];
Point p;
Vector v(b,-a);
if(fabs(a)>fabs(b))p=Point(-c/a,);
else p=Point(,-c/b);
l[cnt++]=line(p,v);
}
if(flag)
{
l[cnt++]=line(Point(,),Vector(,-));
l[cnt++]=line(Point(,),Vector(,));
l[cnt++]=line(Point(,),Vector(-,));
if(halfplanintersection(l,cnt,poly)==)flag=;
}
if(flag)puts("Yes");
else puts("No");
} }return ;
}

uva 1298 - Triathlon的更多相关文章

  1. uva 2218 Triathlon

    题意:铁人三项赛,给定每个选手游泳,自行车,赛跑三个阶段的平均速度,不知道每段比赛的路程,询问当前这个选手能否胜利. 思路:把题意转化为一个不等式,设比赛长度是1,如果i要战胜j,x.y分别是第一阶段 ...

  2. UVALive 4639 && SPOJ SPOINTS && POJ 3805 && AOJ 1298 Separate Points 求两个凸包是否相交 难度:3

    https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_probl ...

  3. uva 1354 Mobile Computing ——yhx

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAABGcAAANuCAYAAAC7f2QuAAAgAElEQVR4nOy9XUhjWbo3vu72RRgkF5

  4. UVA 10564 Paths through the Hourglass[DP 打印]

    UVA - 10564 Paths through the Hourglass 题意: 要求从第一层走到最下面一层,只能往左下或右下走 问有多少条路径之和刚好等于S? 如果有的话,输出字典序最小的路径 ...

  5. UVA 11404 Palindromic Subsequence[DP LCS 打印]

    UVA - 11404 Palindromic Subsequence 题意:一个字符串,删去0个或多个字符,输出字典序最小且最长的回文字符串 不要求路径区间DP都可以做 然而要字典序最小 倒过来求L ...

  6. UVA&&POJ离散概率与数学期望入门练习[4]

    POJ3869 Headshot 题意:给出左轮手枪的子弹序列,打了一枪没子弹,要使下一枪也没子弹概率最大应该rotate还是shoot 条件概率,|00|/(|00|+|01|)和|0|/n谁大的问 ...

  7. UVA计数方法练习[3]

    UVA - 11538 Chess Queen 题意:n*m放置两个互相攻击的后的方案数 分开讨论行 列 两条对角线 一个求和式 可以化简后计算 // // main.cpp // uva11538 ...

  8. UVA数学入门训练Round1[6]

    UVA - 11388 GCD LCM 题意:输入g和l,找到a和b,gcd(a,b)=g,lacm(a,b)=l,a<b且a最小 g不能整除l时无解,否则一定g,l最小 #include &l ...

  9. UVA - 1625 Color Length[序列DP 代价计算技巧]

    UVA - 1625 Color Length   白书 很明显f[i][j]表示第一个取到i第二个取到j的代价 问题在于代价的计算,并不知道每种颜色的开始和结束   和模拟赛那道环形DP很想,计算这 ...

随机推荐

  1. MATLAB-ginput函数问题

    functions:Graphical input from mouse or cursor ginput提供了一个十字光标使我们能更精确的选择我们所需要的位置,并返回坐标值.函数调用形式为: [x, ...

  2. 解决codeforces访问慢的问题

    转载至:http://blog.csdn.net/wmx16835/article/details/38639451 前阵子打Codeforces(以下简称CF),每次比赛的时候都要等待网页刷新.不是 ...

  3. 设置checkbox选中,设置radio选中,根据值设置checkbox选中,checkbox勾选

    设置checkbox选中,设置radio选中,根据值设置checkbox选中,checkbox勾选 >>>>>>>>>>>>&g ...

  4. oracle“记录被另一个用户锁住”

    1.查看数据库锁,诊断锁的来源及类型: select object_id,session_id,locked_mode from v$locked_object; 或者用以下命令: select b. ...

  5. MySQL - 启停服务

    Windows 环境 命令行方式 启动 MySQL 服务: net start mysql停止 MySQL 服务: net stop mysql 注:需要以管理员身份启动 cmd 后再执行上述命令. ...

  6. ASP实现https和http之间转化

    HTTPS 是一个安全通信信道,用于在客户计算机和服务器之间交换信息.它使用安全套接字层 (SSL). HTTPS (Secure Hypertext Transfer Protocol) 安全超文本 ...

  7. C#面试基础问题

    传入某个属性的set方法的隐含参数的名称是什么? value,它的类型和属性所声名的类型相同. 如何在C#中实现继承? 在类名后加上一个冒号,再加上基类的名称. C#支持多重继承么? 不支持.可以用接 ...

  8. 【原创】java 流星划过天空

    import java.awt.Color; import java.awt.Graphics; import java.awt.image.BufferedImage; import javax.s ...

  9. NetMQ(ZeroMQ)Client => Server => Client 模式的实现

    ØMQ (也拼写作ZeroMQ,0MQ或ZMQ)是一个为可伸缩的分布式或并发应用程序设计的高性能异步消息库.它提供一个消息队列, 但是与面向消息的中间件不同,ZeroMQ的运行不需要专门的消息代理(m ...

  10. 【html】【13】特效篇--下拉导航

    html代码: <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" ...