📄 1766.cpp
字号:
/* This Code is Submitted by wywcgs for Problem 1766 on 2005-10-20 at 16:05:21 */
#include <cstdio>
#include <cstring>
#include <cmath>
class Point {
public:
double x;
double y;
double distance(Point *p) {
return (x-p->x)*(x-p->x) + (y-p->y)*(y-p->y);
}
};
int main()
{
Point g, d, h;
double dg, dd, ehx, ehy;
bool esc;
char line[256];
while(scanf("%lf %lf %lf %lf\n", &g.x, &g.y, &d.x, &d.y) == 4) {
esc = false;
while(gets(line)) {
if(strlen(line) == 0) {
break;
} else {
sscanf(line, "%lf %lf", &h.x, &h.y);
if(!esc) {
dg = g.distance(&h);
dd = d.distance(&h);
if(dg*4 - dd < 1e-6) {
ehx = h.x;
ehy = h.y;
esc = true;
}
}
}
}
if(esc) {
printf("The gopher can escape through the hole at (%.3lf,%.3lf).\n", ehx, ehy);
} else {
printf("The gopher cannot escape.\n");
}
}
return 0;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -