#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. Selenium webdriver 开始

    最早接触的selenium是 selenium IDE,当时是为了准备论文.为了用IDE还下载了Firefox浏览器.后来接触过两个项目都需要selenium,一个采用selenium webdirv ...

  2. objc_msgSend iOS8 EXC_BAD_ACCESS

    如果方法是没有返回值的,需要强转一个返回类型为void的临时函数指针, void (*objc_msgSendTyped)(id self, SEL _cmd, id obj, id arg1) = ...

  3. XSLT学习

    XSL 语言 XSL(eXtensible Stylesheet Language)是可扩展样式表语言,是一种用于以可读格式呈现 XML(标准通用标记语言的子集)数据的语言. XSL与xml CSS ...

  4. [置顶] 【Git入门之八】分支管理

    原创作品,转载请标明:http://blog.csdn.net/jackystudio/article/details/12309385 1.分支又是神马? 我为什么说又是... 分支就是一个我们能通 ...

  5. fedorea19安装redis

    Redis 安装: $ wget http://redis.googlecode.com/files/redis-2.4.5.tar.gz $ tar xzf redis-2.4.5.tar.gz $ ...

  6. AFNetworking (3.1.0) 源码解析 <三>

    今天要介绍的是Reachability文件夹下的AFNetworkReachabilityManager类.通过字面意思我们就可以知道AFNetworkReachabilityManager是用来监测 ...

  7. Object -C 数组 -- 笔记

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

  8. TortoiseGit上传代码到GitHub

    Github是管理软件开发的首选托管网站,12306的火车票插件一时让国内当时很多小白开发者(当然也包括我)认识到了这个网站.GitHub可以托管各种git库,并提供一个web界面,与 SourceF ...

  9. java中基于TaskEngine类封装实现定时任务

    主要包括如下几个类: 文章标题:java中基于TaskEngine类封装实现定时任务 文章地址: http://blog.csdn.net/5iasp/article/details/10950529 ...

  10. Java 编程的动态性,第3部分: 应用反射--转载

    在 上个月的文章中,我介绍了Java Reflection API,并简要地讲述了它的一些基本功能.我还仔细研究了反射的性能,并且在文章的最后给出了一些指导方针,告诉读者在一个应用程序中何时应该使用反 ...