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 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100
|
#pragma comment(linker, "/STACK:102400000,102400000") #include <algorithm> #include <iostream> #include <cstdlib> #include <cstring> #include <sstream> #include <vector> #include <cstdio> #include <bitset> #include <string> #include <cmath> #include <deque> #include <queue> #include <stack> #include <map> #include <set> using namespace std; typedef long long ll; const double pi = acos(-1.0); const int eps = 1e-10; const int mod = 1e9 + 7; #define debug(a) cout << "*" << a << "*" << endl const int INF = 0x3f3f3f3f; const int maxn = 1e5 + 5;
int t, n; double ans;
struct node { int x, y; double angel, r; node(int _x = 0, int _y = 0, double _angel = 0, double _r = 0) : x(_x), y(_y), r(_r), angel(_angel){}; } a[maxn];
node point;
double get_r(node a, node b) { return (a.x - b.x) * (a.x - b.x) + (a.y - b.y) * (a.y - b.y); }
ll read() { ll x = 0,f = 1; char ch = getchar(); while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); } while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); } return x * f; }
int main() {
scanf("%d", &t); for (int k = 1; k <= t; k++) { ans = 0; n = read(); for (int i = 0; i < n; i++) { a[i].x = read(); a[i].y = read(); } point.x = read(); point.y = read();
for (int i = 0; i < n; i++) { a[i].r = get_r(a[i], point); double d1 = get_r(a[i], a[(i + 1) % n]); double d2 = get_r(a[i], a[(i + n - 1) % n]); double d3 = get_r(a[(i + 1) % n], a[(i + n - 1) % n]); ans += sqrt(a[i].r) * (pi - acos((d1 + d2 - d3) / (2 * sqrt(d1) * sqrt(d2)))) ; }
printf("Case #%d: %.3lf\n", k, ans); } return 0; }
|