1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 |
#include <iostream> #include <stdio.h> #include <vector> #include <math.h> using namespace std; int main() { int n; double Dg,Dd; double x1,y1,x2,y2; double a,b,Hx,Hy; bool caught = true; while(cin>>n) { cin>>x1>>y1>>x2>>y2; caught = true; for(int i=0;i<n;i++) { cin>>a>>b; if(!caught) continue; Dg = sqrt((a-x1)*(a-x1)+(b-y1)*(b-y1)); Dd = sqrt((a-x2)*(a-x2)+(b-y2)*(b-y2)); double t = (Dg*2)/Dd; if(t>1) { caught=1; } else { Hx= a; Hy= b; caught=0; } } if(!caught) printf("The gopher can escape through the hole at (%.3lf,%.3lf).\n",Hx,Hy); //cout<<"The gopher can escape through the hole at ("<<Hx<<","<<Hy<<").\n"; else cout<<"The gopher cannot escape.\n"; } return 0; } |