#include<iostream> #include<vector> #include<algorithm> #include<string> #include<climits> #include<cmath> #include<unordered_map> #include<set> using namespace std; int main() { double x1, x2, y1, y2, r; while (cin >> x1 >> y1 >> x2 >> y2 >> r) { double len = sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2)); if (len == 0) { cout << "重合" << endl; continue; } if (len > r * 2) { cout << "相离" << endl; continue; } if (len == r * 2) { cout << "相切" << endl; continue; } if (len < r * 2) { cout << "相交 "; double ang1 = acos((r * r + len * len - r * r) / (2 * r * len)); double ang2 = acos((r * r + len * len - r * r) / (2 * r * len)); double res = ang1 * r * r + ang2 * r * r - r * len * sin(ang1); printf("%.2lf\n", res); } } } |
Double click to view unformatted code.