/*第一道离散化的题目,虽然是水题,不过还是很高兴。。。*/

 #include<cstdio>
#include<algorithm>
#include<cstring>
using namespace std;
struct rect
{
double x1,x2,y1,y2;
};
#define max 103<<1
rect a[max>>];
double x[max],y[max];
bool flag[max][max];
int n;
double sum; void solve()
{
for(int i=;i<n;i++)
{
for(int j=;j<n<<;j++)
{
if(x[j]>=a[i].x2)
break;
if(x[j]<a[i].x1)
continue;
for(int k=;k<n<<;k++)
{
if(y[k]>=a[i].y2)
break;
if(y[k]<a[i].y1)
continue;
flag[j][k]=true;
}
}
}
for(int i=;i<n<<;i++)
for(int j=;j<n<<;j++)
{
if(flag[i][j])
sum+=(x[i+]-x[i])*(y[j+]-y[j]);
}
} int main()
{
int k=;
while(~scanf("%d",&n)&&n)
{
int cnt=;
for(int i=;i<n;i++)
{
scanf("%lf%lf%lf%lf",&a[i].x1,&a[i].y1,&a[i].x2,&a[i].y2);
x[cnt]=a[i].x1;y[cnt]=a[i].y1;cnt++;
x[cnt]=a[i].x2;y[cnt]=a[i].y2;cnt++;
}
sort(x,x+cnt);
sort(y,y+cnt);
sum=;
memset(flag,false,sizeof(flag));
solve();
printf("Test case #%d\n",k++);
printf("Total explored area: %.2lf\n\n",sum);
}
}

最新文章

  1. 获取终端ip地址
  2. f4: Facebook’s Warm BLOB Storage System——Erasure Code
  3. POJ 1469
  4. Hive的JDBC使用&amp;并把JDBC放置后台运行
  5. How to open .ccproj in VS2010?
  6. Paxos算法(转)
  7. 搜索与DP:SLIKAR
  8. 单机使用tungsten 同步mysql数据到mongodb
  9. ZOJ 3430 Detect the Virus(AC自动机)
  10. VC生成lib的_stdcall函数名与mingw生成的不一致
  11. 快速构建Windows 8风格应用3-打包发布应用
  12. 想成为Java高级工程师的看过来
  13. 分布式文件系统FastDFS如何做到高可用
  14. Delphi过程和函数中变量的作用域
  15. openwrt 域名ping不通 修改dns
  16. 浅谈 Unix I/O 模型
  17. 如何优化代码中大量的if/else,switch/case?
  18. Oracle数据库web维护管理及监控
  19. How can For each...
  20. 【剑指offer】数组中出现次数超过数组长度一半的数字,C++实现

热门文章

  1. Johnson–Lindenstrauss 定理-Johnson–Lindenstrauss lemma
  2. Java驼峰和下划线互相转化
  3. java内存模型JMM理解整理
  4. React中的this.props.children
  5. Hibernate 查询语言
  6. Docker系列(十四):Kubernetes API和源码分析
  7. 2019-9-2-C#判断文件属于文本或二进制
  8. 2018-11-26-win10-uwp-获取窗口的坐标和宽度高度
  9. Python :route的用法以及Http方法
  10. Kubernetes集群环境准备