#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. IT码农哥放弃50万年薪:辞职卖咖喱凉皮(背后深藏功与名)_互联网的一些事

    IT码农哥放弃50万年薪:辞职卖咖喱凉皮(背后深藏功与名)_互联网的一些事 IT码农哥放弃50万年薪:辞职卖咖喱凉皮(背后深藏功与名)

  2. .Hibernate一对一映射与组件映射

    1.按照外键映射(Hibernate提供了两种映射一对一关联关系的方式:按照外键映射和按照主键映射) 实现需要: 创建实体类Users1和Resume1 public class Users1 { p ...

  3. Django学习笔记(五)—— 表单

    疯狂的暑假学习之  Django学习笔记(五)-- 表单 參考:<The Django Book> 第7章 1. HttpRequest对象的信息 request.path         ...

  4. Android SimpleAdapter GridView (网格图片点击放大显示)

    GridView网格视图 GridView网格视图是按照行,列分布的方式来显示多个组件,通常用于显示图片或是图标等,在使用网格视图时,首先需要要在屏幕上添加GridView组件. 常用属性: 1. a ...

  5. CentOS 6.3下rsync服务器的安装与配置[转]

    CentOS 6.3下rsync服务器的安装与配置   一.rsync 简介 Rsync(remote synchronize)是一个远程数据同步工具,可通过LAN/WAN快速同步多台主机间的文件,也 ...

  6. Android(java)学习笔记259:JNI之NDK开发步骤

    1. NDK开发步骤(回忆一下HelloWorld案例): (1)创建工程 (2)定义native方法 (3)创建jni文件夹 (4)创建c源文件放到jni文件夹 (5)拷贝jni.h头文件到jni目 ...

  7. 【网络流#1】hdu 3549 - 最大流模板题

    因为坑了无数次队友 要开始学习网络流了,先从基础的开始,嗯~ 这道题是最大流的模板题,用来测试模板好啦~ Edmonds_Karp模板 with 前向星 时间复杂度o(V*E^2) #include& ...

  8. android常用http框架介绍

    测试数据 1.HttpURLConnection:在Android 2.2版本之前,HttpClient拥有较少的bug,因此使用它是最好的选择.而在Android 2.3版本及以后,HttpURLC ...

  9. 自定义控件 TextView 歌词 Lrc

    演示 <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE" /> < ...

  10. struts2获取request、session、application

    struts2获取request.session.application public class LoginAction extends ActionSupport implements Reque ...