Problem | Verdict | Lang | Time | Best | Rank | Submit Time |
---|---|---|---|---|---|---|
| discuss10310 - | Accepted | C++11 | 0.000 | 0.000 | 452 | 1 mins ago |
Suggest:
- Because the dog run better x2 than mouse
=> mouse escape <=> distance(mouse -> hole) * 2 < distance(dog -> hole)
#include<bits/stdc++.h>
using namespace std;
double sqr(double x){
return x*x;
}
double distance(double x1, double y1, double x2, double y2){
return sqrt(sqr(x1-x2) + sqr(y1-y2));
}
int main(){
ios::sync_with_stdio(false);
cin.tie(nullptr);
int n;
double x1, x2, y1, y2;
while(cin >> n >> x1 >> y1 >> x2 >> y2){
vector<pair<double, double>> a;
while(n--){
double x, y; cin >> x >> y;
a.push_back({x,y});
}
bool escape = false;
for(auto p:a){
double x = p.first;
double y = p.second;
double d1 = distance(x, y, x1, y1);
double d2 = distance(x, y, x2, y2);
if (d1*2 - d2 < 0.000001){
escape = true;
cout<<"The gopher can escape through the hole at ("<<fixed<<setprecision(3)<<x<<","<<y<<").\n";
break;
}
}
if (not escape)
cout<<"The gopher cannot escape.\n";
}
}
No comments:
Post a Comment