#include #include #include #include using namespace std; typedef complex P; double getWidth(vector

&g, int x){ double m = 1e10, M = -1e10; for(int i=0;i real(b)) swap(a, b); if(real(a) != real(b) && real(a) <= x && x <= real(b)){ double mid = (double)(x-real(a))/(real(b)-real(a)); double d = imag(a)*(1-mid)+imag(b)*mid; m = min(d, m); M = max(d, M); } } return max(0.0, M-m); } int main(){ int n, m; ifstream fin("I.in"); while(fin >> m >> n, m){ vector

gy(m), gz(n); int sy = 100, ey = -100, sz = 100, ez = -100; for(int i=0;i> real(gy[i]) >> imag(gy[i]); sy = min(sy, real(gy[i])); ey = max(ey, real(gy[i])); } for(int i=0;i> real(gz[i]) >> imag(gz[i]); sz = min(sz, real(gz[i])); ez = max(ez, real(gz[i])); } double res = 0.0; for(int i=max(sy, sz);i+1<=min(ey, ez);i++){ double py = getWidth(gy, i), cy = getWidth(gy, i+1), pz = getWidth(gz, i), cz = getWidth(gz, i+1); res += (cy*cz+(cy+py)*(cz+pz)+py*pz)/6.0; } printf("%.4lf\n", res); } }