The following codes both get WA:
Code: Select all
#include <stdio.h>
long long dist(long long a,long long b,long long x,long long y) {
return (a-x)*(a-x)+(b-y)*(b-y);
}
int main()
{
double ddx,ddy,dgx,dgy,dx,dy;
long long ldx,ldy,lgx,lgy,lx,ly;
int N;
while (scanf ("%d %lf %lf %lf %lf",&N,&ddx,&ddy,&dgx,&dgy)==5) {
int escape=0;
ldx=(long long)(ddx*1000ULL);
ldy=(long long)(ddy*1000ULL);
lgx=(long long)(dgx*1000ULL);
lgy=(long long)(dgy*1000ULL);
for (int i=0;i<N;i++) {
scanf ("%lf %lf",&dx,&dy);
lx=(long long)(dx*1000ULL);
ly=(long long)(dy*1000ULL);
if (escape==0) {
if ( (4ULL*dist(ldx,ldy,lx,ly)) <= (dist(lgx,lgy,lx,ly)) ) {
printf ("The gopher can escape through the hole at (%.3lf,%.3lf).\n",dx,dy);
escape=1;
}
}
}
if (escape==0) printf ("The gopher cannot escape.\n");
}
return 0;
}
Code: Select all
#include <stdio.h>
double dist(double a,double b,double x,double y) {
return (a-x)*(a-x)+(b-y)*(b-y);
}
int main()
{
double dx1,dy1,dx2,dy2;
double dtx,dty;
int N,esc=0;
while (scanf ("%d %lf %lf %lf %lf",&N,&dx1,&dy1,&dx2,&dy2)==5) {
esc=0;
for (int i=0;i<N;i++) {
scanf ("%lf %lf",&dtx,&dty);
if (esc==0) {
if (4.0*dist(dx1,dy1,dtx,dty)<=dist(dx2,dy2,dtx,dty)) {
printf ("The gopher can escape through the hole at (%.3lf,%.3lf)\n",dtx,dty);
esc=1;
}
}
}
if (esc==0) printf ("The gopher cannot escape.\n");
}
return 0;
}
I just don't know where is the problem.