#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
struct pointt
{
double x, y;
pointt(double x, double y) :x(x), y(y)
{}
pointt()
{}
};
pointt operator+(pointt a, pointt b)
{
return pointt(a.x + b.x, b.y + a.y);
}
pointt operator-(pointt a, pointt b)
{
return pointt(a.x - b.x, a.y - b.y);
}
pointt operator*(pointt a, double t)
{
return pointt(a.x*t, a.y*t);
}
double operator*(pointt a, pointt b)
{
return a.x*b.x + a.y*b.y;
}
double dot(pointt a, pointt b)
{
return a.x*b.y - a.y*b.x;
}
double length(pointt a)
{
return sqrt(a*a);
}
struct linee
{
pointt p1, vec, verti;
double arc;
linee(pointt a, pointt b) :p1(a), vec(b - a)
{
arc = atan2(vec.y, vec.x);
double l = length(vec);
verti.x = -vec.y / l; verti.y = vec.x / l;
}
linee()
{}
bool operator<(linee b)
{
return arc < b.arc;
}
};
bool isonleft(pointt a, linee b)
{
pointt c = a - b.p1;
return dot(c, b.vec) < 0;
}
pointt inter(linee a, linee b)
{
pointt c = a.p1 - b.p1;
if (fabs(dot(b.vec, a.vec)) < 1e-10)return pointt(1000000000, 1000000000);
double t = dot(c, b.vec) / dot(b.vec, a.vec);
return a.p1 + a.vec*t;
}
linee realline[20050];
linee line[200550];
pointt point[20050];
double ans;
int edgetot;
void halfmat(linee *l, int n)
{
sort(l, l + n);
int first = 0; int last = 0;
realline[first] = l[0];
for (int i = 1; i < n; i++)
{
while ((last - first)>0 && !isonleft(point[last - 1], l[i]))last--;
while ((last - first) > 0 && !isonleft(point[first], l[i]))first++;
if (fabs(dot(l[i].vec, realline[last].vec)) < 1e-10)continue;
realline[++last] = l[i];
if (last - first > 0)point[last - 1] = inter(realline[last], realline[last - 1]);
}
while ((last - first) > 0 && !isonleft(point[last - 1], realline[first]))last--;
if ((last - first) > 0)point[last] = inter(realline[first], realline[last]);
if ((last - first) <= 1)
return;
for (int i = first + 2; i <= last; i++)
{
ans += fabs(dot(point[i] - point[first], point[i - 1] - point[first]));
}
ans /= 2;
}
int main()
{
int n;
scanf("%d", &n);
line[edgetot++] = linee(pointt(0, 0), pointt(10000, 0)); line[edgetot++] = linee(pointt(10000, 0), pointt(10000, 10000));
line[edgetot++] = linee(pointt(10000, 10000), pointt(0, 10000)); line[edgetot++] = linee(pointt(0, 10000), pointt(0, 0));
for (int i = 0; i < n; i++)
{
pointt a, b;
scanf("%lf%lf%lf%lf", &a.x, &a.y, &b.x, &b.y);
line[edgetot++] = linee(a, b);
}
halfmat(line,edgetot);
printf("%.1lf\n",ans);
return 0;
}
终于过了。。。。。23333333