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. jquery动态添加元素无法触发绑定事件的解决方案。

    jquery动态添加元素无法触发绑定的事件的解决方案. ╭(●`∀´●)╯二狗最近在工作中遇到一个问题,即当用jquery动态添加元素后,发现给动态添加的元素却无法触发事件(╯#-_-)╯╧═╧ ( ...

  2. javascript基础笔记学习

    /** * Created by Administrator on 2016/12/26. */ /* var box; alert( typeof box); box是Undefined类型,值是u ...

  3. jquery append

    将已经存在的一个dom对象A,通过jquery append插入另一个dom对象B,将会改变dom树结构--即A成为了B的子元素. 举个例子: js: $(".table-container ...

  4. Maven assembly插件输出文件乱码问题

    使用Maven的<artifactId>maven-assembly-plugin</artifactId>插件导致输出的XML配置文件源文件的中文注释变成乱码,排查了多个地方 ...

  5. ListView的优化

    1. ListView须要设置adapter,它的item是通过adapter的方法getView(int position, View convertView, ViewGroup parent)获 ...

  6. swift开发笔记24 解决键盘遮挡输入框 的方法

    很简单,就是开始输入时把整个view的frame上移,也就是把y值减小就行了,至于减少多少自己调 ,也可以动态获取参见(http://blog.csdn.net/lengshengren/articl ...

  7. java byte数组与int,long,short,byte转换

    public class DataTypeChangeHelper { /** * 将一个单字节的byte转换成32位的int * * @param b * byte * @return conver ...

  8. Java基础知识强化91:DateFormat类之DateFormat实现日期和字符串的相互转换

    1. DateFormat类概述: DateFormat 是日期/时间格式化子类的抽象类,它以与语言无关的方式格式化并解析日期或时间. 是抽象类,所以使用其子类SimpleDateFormat 2.  ...

  9. 11-C#反射机制

    C#反射机制 转自:http://blog.csdn.net/educast/article/details/2894892 反射的用途:    (1)使用Assembly定义和加载程序集,加载在程序 ...

  10. Error prompt:“xxx is not in the sudoers file”----Solution

    //Situation    System prompts "xxx is not in the sudoers file"(xxx equals the user name) w ...