http://acm.timus.ru/problem.aspx?space=1&num=1348

 #include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
const double eps=1e-; double dcmp(double x){
if(fabs(x)<eps) return ;
else return x<?-:;
} double sqr(double x)
{
return x*x;
}
struct node
{
double x,y;
}st3,st1,st2; double cross(node a,node b)
{
return (a.x*b.y-a.y*b.x);
}
double dot(node a,node b)
{
return (a.x*b.x+a.y*b.y);
}
double dis(double x1,double y1,double x2,double y2)
{
return sqrt(sqr(x1-x2)+sqr(y1-y2));
} double distance1(node p,node a,node b)
{
if(a.x==b.x&&a.y==b.y) return dis(p.x,p.y,a.x,a.y);
node p1; p1.x=b.x-a.x;p1.y=b.y-a.y;
node p2; p2.x=p.x-a.x;p2.y=p.y-a.y;
node p3; p3.x=p.x-b.x;p3.y=p.y-b.y;
if(dcmp(dot(p1,p2))<) return dis(p.x,p.y,a.x,a.y);
else if(dcmp(dot(p1,p3))>) return dis(p.x,p.y,b.x,b.y);
else return (fabs(cross(p1,p2))/dis(a.x,a.y,b.x,b.y));
} int main()
{
double x1,y1,x2,y2,x3,y3,l;
scanf("%lf%lf%lf%lf",&x1,&y1,&x2,&y2);
scanf("%lf%lf%lf",&x3,&y3,&l);
st1.x=x1;st1.y=y1;
st2.x=x2;st2.y=y2;
st3.x=x3;st3.y=y3;
double l1=dis(st3.x,st3.y,st1.x,st1.y);
double l2=dis(st3.x,st3.y,st2.x,st2.y);
double l3=distance1(st3,st1,st2);
double min1=min(l1,min(l2,l3));
double max1=max(l1,max(l2,l3));
double ans1=min1-l;
double ans2=max1-l;
if(ans1<eps) ans1=;
if(ans2<eps) ans2=;
printf("%.2lf\n",ans1);
printf("%.2lf\n",ans2);
return ;
}

ural 1348 Goat in the Garden 2的更多相关文章

  1. sgu 1348 Goat in the Garden 2【点到线段的距离】

    链接: http://acm.timus.ru/problem.aspx?space=1&num=1348 http://acm.hust.edu.cn/vjudge/contest/view ...

  2. ural 1084 Goat in the Garden

    #include <cstdio> #include <cstring> #include <cmath> #include <algorithm> u ...

  3. POJ 1518 A Round Peg in a Ground Hole【计算几何=_=你值得一虐】

    链接: http://poj.org/problem?id=1584 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22013#probl ...

  4. POJ 1584 A Round Peg in a Ground Hole【计算几何=_=你值得一虐】

    链接: http://poj.org/problem?id=1584 http://acm.hust.edu.cn/vjudge/contest/view.action?cid=22013#probl ...

  5. OJ题解记录计划

    容错声明: ①题目选自https://acm.ecnu.edu.cn/,不再检查题目删改情况 ②所有代码仅代表个人AC提交,不保证解法无误 E0001  A+B Problem First AC: 2 ...

  6. 训练报告 (2014-2015) 2014, Samara SAU ACM ICPC Quarterfinal Qualification Contest

    Solved A Gym 100488A Yet Another Goat in the Garden   B Gym 100488B Impossible to Guess Solved C Gym ...

  7. ural 2064. Caterpillars

    2064. Caterpillars Time limit: 3.0 secondMemory limit: 64 MB Young gardener didn’t visit his garden ...

  8. HDU5977 Garden of Eden(树的点分治)

    题目 Source http://acm.hdu.edu.cn/showproblem.php?pid=5977 Description When God made the first man, he ...

  9. hdu-5977 Garden of Eden(树分治)

    题目链接: Garden of Eden Time Limit: 10000/5000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/ ...

随机推荐

  1. JSP学习笔记(三):简单的Tomcat Web服务器

    注意:每次对Tomcat配置文件进行修改后,必须重启Tomcat 在E盘的DATA文件夹中创建TomcatDemo文件夹,并将Tomcat安装路径下的webapps/ROOT中的WEB-INF文件夹复 ...

  2. Resizable 2th click not working

    here's a simple solution.  just destroy the resizable function, then rebuild it. try { $("#div& ...

  3. Object -C NSSet -- 笔记

    // //  main.m //  NSSET // //  Created by facial on 25/8/15. //  Copyright (c) 2015 facial_huo. All ...

  4. linux if 判断字符串是否相等

    在命令行中修改时间: 如果linux系统时间等于2017-09-09,则ok:否则将当前系统时间修改为2017-09-09 var=`date '+%Y-%m-%d'`;if [ "$var ...

  5. 启动android默认浏览器

    一.启动android默认浏览器 Intent intent = new Intent();         intent.setAction("android.intent.action. ...

  6. IIS rewrite映射规则语法格式

    IIS rewrite映射规则语法格式,特殊符号:&请用& amp;代替,否则异常. <configuration> <system.webServer> &l ...

  7. linux 管道命令 小记

    管道命令(pipe) 使用“|”界定符号 管道命令必须能够接收来自前一个命令的数据成为standard input才能继续处理 1.选取命令:cut, grep.分析数据,取出我们想要的. -cut ...

  8. python对象(腌制)

    python的内置对象类型主要有数字,字符串,列表,元祖,字典,集合等等,在python中,一切皆为对象 #腌制在python中如果我们有一些对象需要持久性存储,并且不丢失我们这个对象的类型与数据,我 ...

  9. Android-Eclipse汉化

    首先下载好汉化包 解压后得到eclipse文件夹 然后在eclipse根目录下创建language文件夹 将eclipse文件夹放入 在eclipse根目录下创建links文件夹 然后在里面添加这个文 ...

  10. ASP.NET 2.0服务器控件开发的基本概念(转载)

    利用ASP.NET 2.0技术,创建Web自定义服务器控件并不是一件轻松的事情.因为,这需要开发人员了解并能够灵活应用多种Web开发技术,例如,CSS样式表.客户端 脚本语言..NET开发语言.服务器 ...