HDU 2056

来源:互联网 发布:it618淘宝客导购 编辑:程序博客网 时间:2024/06/08 02:05
#include <stdio.h>#include <iostream>#include <math.h>using namespace std;int main(){    double c,w,g;    double x1,x2,x3,x4,y1,y2,y3,y4,t;    while(scanf("%lf %lf %lf %lf %lf %lf %lf %lf",&x1,&y1,&x2,&y2,&x3,&y3,&x4,&y4)!=EOF)    {        if (x1>x2) t=x1,x1=x2,x2=t;        if (y1>y2) t=y1,y1=y2,y2=t;        if (x3>x4) t=x3,x3=x4,x4=t;        if (y3>y4) t=y3,y3=y4,y4=t;            x1=max(x1,x3);            y1=max(y1,y3);            x2=min(x2,x4);            y2=min(y2,y4);        printf("%.2lf\n",x1>x2||y1>y2?0:(x2-x1)*(y2-y1));    }}


一道超级水题,但是我居然是3A.................好吧,其实就是判断矩阵重叠的部分。

只要判断好边界和0值就好。我读题的时候还以为x1=y1,x2=y2,x3-=y3,x4=y4。是在不应该。

基本上一般的都会1A吧。