思路:
直接计算线段右侧的点不出现的概率。
c o d e code code
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
const int MAXN = 1e2 + 10;
int n;
struct node {
double x, y, p;
}a[MAXN];
double ans;
bool judge(double x, double y, double x1, double y1, double x2, double y2) {
return (x - x2) * (y1 - y2) - (x1 - x2) * (y - y2) < 0;
}
int main() {
freopen("polygons.in", "r", stdin);
freopen("polygons.out", "w", stdout);
scanf("%d", &n);
for(int i = 1; i <= n; i ++) scanf("%lf%lf%lf", &a[i].x, &a[i].y, &a[i].p);
for(int i = 1; i <= n; i ++)
for(int j = 1; j <= n; j ++) {
if(i == j) continue;
double g = a[i].x * a[j].y - a[i].y * a[j].x;
for(int k = 1; k <= n; k ++) {
if(k == i || k == j) continue;
if(judge(a[i].x, a[i].y, a[j].x, a[j].y, a[k].x, a[k].y)) g *= 1 - a[k].p;
}
ans += a[i].p * a[j].p * (g / 2);
}
printf("%.7lf", ans + 1e-8);
return 0;
}