Lightoj1211——Intersection of Cubes(立方体的交)
来源:互联网 发布:linux就该这么学百度云 编辑:程序博客网 时间:2024/04/29 23:22
You are given n cubes, each cube is described by two points in 3D space: (x1, y1, z1) being one corner of the cube and (x2, y2, z2) being the opposite corner. Assume that the sides of each of the cubes are parallel to the axis. Your task is to find the volume of their intersection.
Input
Input starts with an integer T (≤ 100), denoting the number of test cases.
Each case starts with a line containing an integer n (1 ≤ n ≤ 100). Each of the next n lines contains six integers x1 y1 z1 x2 y2 z2 (1 ≤ x1, y1, z1, x2, y2, z2 ≤ 1000, x1 < x2, y1 < y2, z1 < z2) where (x1, y1, z1) is the co-ordinate of one corner and (x2, y2, z2) is the co-ordinate of the opposite corner.
Output
For each case, print the case number and volume of their intersection.
Sample Input
2
2
1 1 1 3 3 3
1 1 1 2 2 2
3
7 8 9 20 20 30
2 2 2 50 50 50
13 14 15 18 30 40
Output for Sample Input
Case 1: 1
Case 2: 450
给出底下的坐标和与其相对的坐标,求立方体的交
交集的底坐标由最大的那个决定,顶坐标反之
#include <iostream>#include <cstring>#include <string>#include <vector>#include <queue>#include <cstdio>#include <set>#include <cmath>#include <algorithm>#define INF 0x3f3f3f3f#define MAXN 2005#define Mod 10001using namespace std;int up[MAXN],down[MAXN],tup[MAXN],tdown[MAXN];int main(){ int t,cnt=1; scanf("%d",&t); while(t--) { int n; scanf("%d",&n); for(int i=0; i<3; ++i) scanf("%d",&down[i]); for(int i=0; i<3; ++i) scanf("%d",&up[i]); for(int j=0; j<n-1; ++j) { for(int i=0; i<3; ++i) scanf("%d",&tdown[i]); for(int i=0; i<3; ++i) scanf("%d",&tup[i]); for(int i=0;i<3;++i) { up[i]=min(up[i],tup[i]); down[i]=max(down[i],tdown[i]); } } printf("Case %d: ",cnt++); bool flag=false; int area=1; for(int i=0;i<3;++i) { if(down[i]>up[i]) flag=true; area*=(up[i]-down[i]); } if(!flag) printf("%d\n",area); else printf("0\n"); } return 0;}
- Lightoj1211——Intersection of Cubes(立方体的交)
- lightoj1211 Intersection of Cubes
- light oj 1211 - Intersection of Cubes (立方体的交集的体积)
- UVa Problem 10051 Tower of Cubes (立方体之塔)
- LightOJ 1211 Intersection of Cubes
- light oj 1211 - Intersection of Cubes (计算几何)
- 547.Intersection of Two Arrays-两数组的交(容易题)
- 548.Intersection of Two Arrays II-两数组的交 II(容易题)
- Intersection of Two Arrays 两数组的交
- Intersection of Two Arrays II 两数组的交
- POJ 1410 Intersection(矩形和线段的交,线段的交)
- HDU5120 Intersection 【求圆的面积交】
- HDU 5120 Intersection(圆的面积交)
- hdu acm 5120 Intersection(圆交)
- leetcode——Intersection of Two Arrays
- 三维重建移动立方体法(Marching Cubes Algorithm)的查找表的构造
- uva 10051 Tower of Cubes(dp)
- lightoj 1211 立方体面积交
- 《数据库系统概论》学习总结
- 2. JMeter中非常重要的几个概念
- URAL - 1748 The Most Complex Number(数论+搜索)
- Hive常用命令总结
- python 国际化一词多义翻译
- Lightoj1211——Intersection of Cubes(立方体的交)
- DataTable
- Sqlite
- js模态框插件
- 深度优先搜索
- volatile的作用和菱形继承问题
- SpringMVC与Struts2区别与比较总结
- JZOJ 4294. 复制&粘贴2
- leetcode Maximum Gap