Light Oj 1211 计算多个立方体重叠部分体积
2014-08-07 15:34
671 查看
Intersection of Cubes
Time Limit:500MS Memory Limit:32768KB 64bit IO Format:%lld & %llu
Submit
Status
Practice
LightOJ 1211
Description
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
Sample Output
Case 1: 1
Case 2: 450
Time Limit:500MS Memory Limit:32768KB 64bit IO Format:%lld & %llu
Submit
Status
Practice
LightOJ 1211
Description
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
Sample Output
Case 1: 1
Case 2: 450
<span style="color:#000099;">/********************************************* author : Grant Yuan time : 2014.8.7 algorithm: 计算几何 source : Light Oj 1211 explain : 求几个正方体重叠部分的体积 ***********************************************/ #include<iostream> #include<cstdio> #include<cstdlib> #include<cstring> #include<algorithm> #define INF 0x3fffffff using namespace std; int t,n,a[7]; int ans; int main() { scanf("%d",&t);int c; for(int i=1;i<=t;i++) { scanf("%d",&n); a[1]=a[2]=a[3]=0; a[4]=a[5]=a[6]=INF; for(int j=1;j<=n;j++) { for(int k=1;k<=3;k++) { scanf("%d",&c); if(c>a[k]) a[k]=c; } for(int k=4;k<=6;k++) { scanf("%d",&c); if(c<a[k]) a[k]=c; } } if(a[4]>a[1]&&a[5]>a[2]&&a[6]>a[3]) { ans=(a[4]-a[1])*(a[5]-a[2])*(a[6]-a[3]); printf("Case %d: %d\n",i,ans);} else printf("Case %d: 0\n",i); } return 0; } </span>
相关文章推荐
- Light Oj 1211 计算多个立方体重叠部分体积
- light oj 1211 - Intersection of Cubes (立方体的交集的体积)
- 【java学习记录】2.定义一个计算矩形面积、立方体和球体体积的类,该类完成计算的方法用静态方法实现
- 计算立方体体积的inline函数
- 用构造函数计算不同立方体的体积
- light oj 1211 - Intersection of Cubes (计算几何)
- 【Algorithm】 重叠部分面积计算
- [ACM_模拟][ACM_数学] LA 2995 Image Is Everything [由6个视图计算立方体最大体积]
- 使用java语言基础部分知识,做一个简易的2个数之间的关于算术运算符的计算。
- Light oj 1027 A Dangerous Maze ----计算期望
- C - 计算球体积
- 杭电ACM--2002计算求得体积
- 题目242-计算球体积
- Android 应用程序分析之Calculator ----核心计算部分的理解和高精度运算
- 分布式计算:批处理引擎 MapReduce(第二部分)
- 计算球体积
- POJ 2208 已知边四面体六个长度,计算体积
- 检查两个长方形是否有重叠部分
- 计算球的体积
- arcgis engine 计算距离面积体积