uva 10310 - Dog and Gopher

来源:互联网 发布:影视模板源码交易网 编辑:程序博客网 时间:2024/06/06 14:03
#include <stdio.h>#include <string.h>#include <cmath>#include <iostream>using namespace std;struct point{double x, y;};int main(){  int n;  point g, d, h[100000];  while(scanf("%d%lf%lf%lf%lf", &n, &g.x, &g.y, &d.x, &d.y)!=EOF)  {    for(int i = 0; i < n; i++)      scanf("%lf%lf", &h[i].x, &h[i].y);    int i, ok = 0;    for(i = 0; i < n; i++)      if((pow(d.x-h[i].x, 2) + pow(d.y-h[i].y, 2)) >= 4.0*(pow(g.x - h[i].x, 2) +  pow(g.y - h[i].y, 2)))      {ok=1;break;}      if(ok) printf("The gopher can escape through the hole at (%.3lf,%.3lf).\n", h[i].x, h[i].y);      else cout << "The gopher cannot escape." << endl;  }  return 0;}


原创粉丝点击