123456789101112131415161718192021222324252627282930313233343536373839404142434445464748
#include<cstdio>#include<cmath>#include<cstring>#define pi 3.14159265using namespace std;int main() { double ans; int T, n, b[128][128], x, y, minx, miny, maxx, maxy; scanf("%d", &T); while (T--) { ans = 0; memset(b, 0, sizeof(b)); scanf("%d", &n); for (int i = 0; i < n; ++i) { scanf("%d%d", &x, &y); if (i == 0) { minx = maxx = x; miny = maxy = y; } else { if (x < minx) minx = x; if (x > maxx) maxx = x; if (y < miny) miny = y; if (y > maxy) maxy = y; } b[x][y] = 1; } for (int i = minx; i <= maxx + 1; ++i) for (int j = miny; j <= maxy + 1; ++j) { if (b[i-1][j-1] + b[i-1][j] + b[i][j-1] + b[i][j] > 2) ans += 1.0; else if (b[i-1][j-1] + b[i-1][j] + b[i][j-1] + b[i][j] == 1) ans += pi/4; else if (b[i-1][j-1] + b[i-1][j] + b[i][j-1] + b[i][j] == 2) { if ((b[i-1][j-1] == 1 && b[i][j] == 1) || (b[i][j-1] == 1 && b[i-1][j] == 1)) ans += 1.0; else ans += sqrt(3)/4 + pi/6; } } printf("%.5f\n", ans); } return 0;}
返回