超简单题。
以下是我的代码:
#include <cstdio>
#include <cmath>
using namespace std;
const double eps = 1e-8;
double d ( double x1, double y1, double x2, double y2 )
{
return ( x1 - x2 ) * ( x1 - x2 ) + ( y1 - y2 ) * ( y1 - y2 );
}
int main ()
{
#ifndef ONLINE_JUDGE
freopen ( "data.in", "r", stdin );
#endif
int n;
double x1, y1, x2, y2, x, y, ansx, ansy;
bool found;
while ( scanf( "%d%lf%lf%lf%lf", &n, &x1, &y1, &x2, &y2 ) == 5 )
{
found = false;
for ( int i = 1; i <= n; i++ )
{
scanf ( "%lf%lf", &x, &y );
if ( found )
continue;
if ( 4 * d ( x1, y1, x, y ) <= d ( x2, y2, x, y ) )
{
found = true;
ansx = x;
ansy = y;
}
}
//printf ( "%f\n", (double)20000*20000*2 );
if ( !found )
printf ( "The gopher cannot escape.\n" );
else
printf ( "The gopher can escape through the hole at (%.3f,%.3f).\n", ansx, ansy );
}
return 0;
}
posted on 2011-09-08 00:11
lee1r 阅读(624)
评论(1) 编辑 收藏 引用 所属分类:
题目分类:基础/模拟