#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#define maxn 20000
using namespace std;
const double eps=1e-; inline double sqr(double x)
{
return x*x;
}
inline int dcmp(double x)
{
if(fabs(x)<eps) return ;
else return x<?-:;
}
struct node
{
double x,y;
}p[maxn]; double dis(node a,node b)
{
return sqrt(sqr(a.x-b.x)+sqr(a.y-b.y));
} double cross(node a,node b,node c)
{
return (c.x-a.x)*(b.y-a.y)-(c.y-a.y)*(b.x-a.x);
} double dot(node a,node b)
{
return a.x*b.x+a.y*b.y;
}
bool in(node *p,int n,node a)
{
p[n]=p[];p[n+]=p[];
for(int i=; i<n; i++)
{
if(-cross(p[i],p[i+],a)*cross(p[i+],p[i+],a)>eps)
{
return false;
}
}
return true;
} double disten(node pp,node a,node b)
{
if(a.x==b.x&&a.y==b.y) return dis(pp,a);
node st1;st1.x=b.x-a.x; st1.y=b.y-a.y;
node st2;st2.x=pp.x-a.x; st2.y=pp.y-a.y;
node st3;st3.x=pp.x-b.x; st3.y=pp.y-b.y;
if(dcmp(dot(st1,st2))<) return dis(pp,a);
else if(dcmp(dot(st1,st3)>)) return dis(pp,b);
else return fabs(cross(a,b,pp))/(dis(a,b));
} int main()
{
int n;
node c;
scanf("%lf%lf%d",&c.x,&c.y,&n);
double min1=1e10;
for(int i=; i<n; i++)
{
scanf("%lf%lf",&p[i].x,&p[i].y);
}
if(in(p,n,c))
{
printf("%.3lf\n",0.0);
}
else
{
for(int i=; i<n; i++)
{
min1=min(min1,disten(c,p[i],p[i+]));
}
printf("%.3lf\n",*min1);
}
return ;
}

ural 1215 Exactness of Projectile Hit的更多相关文章

  1. URAL 1873. GOV Chronicles

    唔 神题一道 大家感受一下 1873. GOV Chronicles Time limit: 0.5 secondMemory limit: 64 MB A chilly autumn night. ...

  2. [LeetCode] Design Hit Counter 设计点击计数器

    Design a hit counter which counts the number of hits received in the past 5 minutes. Each function a ...

  3. Buffer cache hit ratio性能计数器真的可以作为内存瓶颈的判断指标吗?

    Buffer cache hit ratio官方是这么解释的:“指示在缓冲区高速缓存中找到而不需要从磁盘中读取的页的百分比.” Buffer cache hit ratio被很多人当做判断内存的性能指 ...

  4. LeetCode Design Hit Counter

    原题链接在这里:https://leetcode.com/problems/design-hit-counter/. 题目: Design a hit counter which counts the ...

  5. Breakpoint is not hit

    新拿到一个Silverlight项目,能够正常运行,但是一旦运行起来,断点处由实心点变成了空心的,并警告:The breakpoint will not currently be hit. No sy ...

  6. 后缀数组 POJ 3974 Palindrome && URAL 1297 Palindrome

    题目链接 题意:求给定的字符串的最长回文子串 分析:做法是构造一个新的字符串是原字符串+反转后的原字符串(这样方便求两边回文的后缀的最长前缀),即newS = S + '$' + revS,枚举回文串 ...

  7. ural 2071. Juice Cocktails

    2071. Juice Cocktails Time limit: 1.0 secondMemory limit: 64 MB Once n Denchiks come to the bar and ...

  8. ural 2073. Log Files

    2073. Log Files Time limit: 1.0 secondMemory limit: 64 MB Nikolay has decided to become the best pro ...

  9. ural 2070. Interesting Numbers

    2070. Interesting Numbers Time limit: 2.0 secondMemory limit: 64 MB Nikolay and Asya investigate int ...

随机推荐

  1. ubuntu修改系统环境变量文件导致起不来

    修改/etc/environment文件导致系统起不来. 长按shift,进入恢复界面,然后以root方式登录命令行界面 然后vi修改/etc/environment文件 提示:Unable to o ...

  2. 在windows下MySQLdb/MySQL-python的安装

    学习Python的时候总是遇到各种各样的问题,很多问题我也百度了很久,谷歌了很多,发现很多人也遇到这种问题:但是答案又各种不同,因人而异吧! 问题:windows系统下  安装了mysql数据库   ...

  3. clang和gcc消除警告

    1. clang命令,它的作用是用来消除特定区域的clang的编译警告,-Wgnu则是消除?:警告, 例: #pragma clang diagnostic push #pragma clang di ...

  4. ASP.NET MVC3调用分部视图-PartialView的几种方式(集)

    我们的网页通常会有好几个部分组成,一些公共的区域我们通常会做成PartialView(部分视图),但这些视图并不是完全固定的,所以还是需要 特定的Controller来控制.如果只是静态的html,虽 ...

  5. Understand Rails Authenticity Token

    翻译整理自: http://stackoverflow.com/questions/941594/understand-rails-authenticity-token 主要翻译的是第一个回答,另外结 ...

  6. Android 仿Win8的metro的UI界面(上)

    转载请标明出处:http://blog.csdn.net/lmj623565791/article/details/23441455 昨晚没事手机下载了一些APP,发现现在仿win8的主界面越来越多, ...

  7. TCP/IP协议原理与应用笔记05:TCP/IP协议下的网关

    大家都知道,从一个房间走到另一个房间,必然要经过一扇门.同样,从一个网络向另一个网络发送信息,也必须经过一道“关口”,这道关口就是网关.顾名思义,网关(Gateway)就是一个网络连接到另一个网络的& ...

  8. Android AIDL图解

      代码来自:http://www.cnblogs.com/mandroid/archive/2011/02/26/1965428.html     (XXX.AIDL自动生成的IXXX.java类中 ...

  9. yii 自动生成的内容,分页信息(Displaying 1-10 of 15 results.)如何修改或是yii cgridview template summary

    问的白一点就是 Displaying 1-10 of 15 results 如何翻译 如果搜索的话, 搜这个会出来很多内容 yii cgridview template summary 好了,其他不说 ...

  10. 图片样式 scaleType 属性

    ImageView的属性android:scaleType,即ImageView.setScaleType(ImageView.ScaleType),不同值的意义区别: