mirror of
https://github.com/Kiritow/OJ-Problems-Source.git
synced 2024-03-22 13:11:29 +08:00
1b4d6396e4
2700-2799
35 lines
861 B
C++
35 lines
861 B
C++
# include <stdio.h>
|
|
# include <math.h>
|
|
int r, x, y ;
|
|
double dist(double ax, double ay, double bx, double by)
|
|
{
|
|
return sqrt((ax-bx)*(ax-bx) + (ay-by)*(ay-by)) ;
|
|
}
|
|
void work(int cas)
|
|
{
|
|
double sx = x, sy = y, ex, ey, t ;
|
|
int flag = 0 ;
|
|
while (1)
|
|
{
|
|
scanf ("%lf%lf", &ex, &ey) ;
|
|
if (ex < 0 && ey < 0) break ;
|
|
if (flag) continue ;
|
|
if (dist(sx, sy, ex, ey) <= r+1.0)
|
|
{
|
|
printf ("Firefly %d caught at (%.0lf,%.0lf)\n", cas, ex, ey) ;
|
|
flag = 1 ;
|
|
}
|
|
t = r*1.0 / dist(sx, sy, ex, ey) ;
|
|
sx = sx + (ex-sx)*t ;
|
|
sy = sy + (ey-sy)*t ;
|
|
}
|
|
if (!flag) printf ("Firefly %d not caught\n", cas) ;
|
|
}
|
|
int main ()
|
|
{
|
|
int nCase = 1 ;
|
|
while (scanf ("%d%d%d", &r, &x, &y) && (r||x||y))
|
|
work(nCase++) ;
|
|
return 0 ;
|
|
}
|