doubles(node a, node b, node c) { double ab = dis(a, b); double bc = dis(b, c); double ac = dis(a, c); double p = (ab + bc + ac) / 2; returnsqrt(p * (p - ab) * (p - bc) * (p - ac)); }
intmain() { node p1 = node(0, 0); node p2 = node(1, 1); node p3 = node(2, 0); int t = 10000000; double cur = 0, ans = 0.0; // printf("%.6f\n", cur); srand((unsigned)time(NULL)); while (t--) { double x, y; double ss; while (1) { x = rand() % 1000000 * 2.0 / 1000000.0; y = rand() % 1000000 * 1.0 / 1000000.0;
node nn = node(x, y); ss = max(s(p1, p2, nn), max(s(p1, p3, nn), s(p2, p3, nn))); if (isnan(ss)) continue; if (y >= 0 && x + y <= 2 && y - x <= 0) break; } cur += ss; if (cur >= 1000000.0) { ans += cur / 10000000.0; cur = 0.0; } } //printf("%.6f %.6f\n", ans, cur); ans += (double)cur / 10000000.0; printf("%.6f\n", ans * 36.0); return0; }