#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. Spark Streaming 入门指南

    这篇博客帮你开始使用Apache Spark Streaming和HBase.Spark Streaming是核心Spark API的一个扩展,它能够处理连续数据流. Spark Streaming是 ...

  2. Foundation: Binary Search

    /* Binary search. * * Implementation history: * 2013-10-5, Mars Fu, first version. */ /* [Binary Sea ...

  3. Sublime Text3 配置markdown插件

    sublime是一个亮骚的文本编辑器,而且是跨三大平台,而markdown是一门标记语法,对于记录真是神器,具体语法百度很多,下面教你在sublime上配置markdown. 这两个神器结合起来简直好 ...

  4. ganglia单播配置

    背景:    有时,由于当前网络不支持组播等种种原因,使用gmond默认的配置gmetad不能获取到各个客户端的全部数据,http://x.x.x.x/ganglia页面一个cluster组只能展示一 ...

  5. HDU 2853 Assignment(KM最大匹配好题)

    HDU 2853 Assignment 题目链接 题意:如今有N个部队和M个任务(M>=N),每一个部队完毕每一个任务有一点的效率,效率越高越好.可是部队已经安排了一定的计划,这时须要我们尽量用 ...

  6. CCDictionary&CCArray执行retain()重要点

    CCDictionary也需要执行retain(),否则则跟CCArray,返回则释放对象. 在Lua中,忘记了retain(),导致一些出现gCCDictionary:objectForKey(ke ...

  7. Eclipse、MyEclipse使用git插件(egit)

    在开发Java.JavaEE等相关程序时,我们会用到Eclipse或者MyEclipse,同时使用到git作为版本控制软件,所以我们需要在这些IDE上集成git插件,而egit正是Eclipse基金会 ...

  8. TreeSet与TreeMap

    TreeSet底层使用的存储容器为TreeMap TreeMap使用红黑树(一种自平衡的排序二叉树)实现,检索效率为O(logn) 红黑树的三个基本操作:左旋.右旋.着色 平衡二叉树:空树或左右子树高 ...

  9. 九度OJ 1552座位问题(dp)

    刚开始写的一维数组,但是由于后面的数字较大,要对它取模,所以用一维数组进行减法运算,结果就不对了.所以还是得用二维数组,用dp[n][0]来表示第n位为男生总的方法个数,dp[n][1]表示第n位为女 ...

  10. Linux服务的管理

    1.Linux服务的介绍 系统服务 --某些服务的服务的对象是Linux系统本身,或者Linux系统系统用户,这类服务我们称为系统服务(System Service) 网络服务 --提供给网络中的其他 ...