Special Tetrahedron

Time Limit: 4000/2000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)
Total Submission(s): 328    Accepted Submission(s): 130

Problem Description
Given n points which are in three-dimensional space(without repetition).

Please
find out how many distinct Special Tetrahedron among them. A
tetrahedron is called Special Tetrahedron if it has two following
characters.

1. At least four edges have the same length.

2. If it has exactly four edges of the same length, the other two edges are not adjacent.

 
Input
Intput contains multiple test cases.

The first line is an integer T,1≤T≤20, the number of test cases.

Each case begins with an integer n(n≤200), indicating the number of the points.

The next n lines contains three integers xi,yi,zi, (−2000≤xi,yi,zi≤2000), representing the coordinates of the ith point.

 
Output
For
each test case,output a line which contains"Case #x: y",x represents
the xth test(starting from one),y is the number of Special Tetrahedron.
 
Sample Input
2
4
0 0 0
0 1 1
1 0 1
1 1 0
9
0 0 0
0 0 2
1 1 1
-1 -1 1
1 -1 1
-1 1 1
1 1 0
1 0 1
0 1 1
 
Sample Output
Case #1: 1
Case #2: 6
 
题意:在空间中的点里面找到有多少点可以组成满足下列条件的四面体:
1.至少有四条边相同.
2.在确保4条边相等的情况下,另外的两条边不相邻。
QAQ,昨天4道题止步于网络赛,奈何这个第五道三维几何没做过,被吓住了 TAT ..根本没有1003难嘛。。
题解:枚举对角线,找到所有和对角线两端点相等的点,然后去枚举所有的和对角线距离相等的点(还要判断四点不共面)。因为有两条对角线,所以答案会被算两次。然后是正四面体,我们每条线都被多算了1次,总共算了6次,我们只要其中的一次。所以最终答案为 (ans-same)/2+same/6 = ans/2- same/3...交代码请用G++。。
aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAASAAAAGQCAIAAACBKyqiAAARtElEQVR4nO2dQU7jwBZFWQijL1aD/oC1MGAtkbKKP0YsBXbAIGLQioRUf+CQxI7jOHa9qvdunaNMmiaO6757VI5J0w8JAMx4qH0CAMogGIAhCAZgCIIBGIJgAIYgGIAhCAZgCIIBGIJgAIYgGIAhCAZgCIIBGIJgAIYgGIAhCAZgCIIBGIJgAIYgGIAhCAZg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1vt7BcMunzAVcxCsZZhKCRa0/y7BsMstDKYQ9zowXzDs8gyzKQSCtQmzKcddJswUDLucw3iKMt+HOYJhl3+YUFEQrDWYUGlmWnFTMOwKAUOqwBw3pgXDrigwpwogWDswpzrcNGRCMOwKBKOqxrQn1wTDrlgwrWogWAswrZpM2DIqGHaFg4FV5pozl4JhV0SYWWUQTBtmVp9RcwaCYVdQGJsLLv05Fwy74sLkXIBgqjA5LwwsOgqGXaFheI44dyn7f4IOVUAwRyCYHgjmi6NjCKYBgrmjcwzBNEAwdyCYEgjmkYeHBwTTAMGcgmAaIJhTEEwDBAMwBMEADEEwAEMQDMAQBAMwBMEADEEwAEMQDMAQBAMwBMEADEEwAEMQDMAQBAMwBMEADEEwAEMQDMAQBAMwBMEADEEwAEMQDMAQBAMwBMEADEEwAEMQDMAQBAMwBMEADEEwAEMQDMAQBAMwBMEADEEwAEMQDMAQBAMwBMEADPk/Dq8ooYRMYwwAAAAASUVORK5CYII=" alt="" />
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <map>
#define sqr(x) ((x)*(x))
using namespace std;
const double eps = 1e-;
struct Point
{
double x,y,z;
Point(double x, double y, double z) : x(x), y(y), z(z) {}
Point() {}
Point operator - (const Point & p) const
{
return Point(x-p.x, y-p.y, z-p.z);
}
} p[];
struct Node
{
int idx;
double dis;
}node[];
int sig(double d)
{
return (d>eps) - (d<-eps);
}
//叉乘
Point cross(const Point & a, const Point & b)
{
return Point(a.y*b.z-a.z*b.y, a.z*b.x-a.x*b.z, a.x*b.y-a.y*b.x);
}
Point cross(const Point & o, const Point & a, const Point & b)
{
return cross(a-o,b-o);
}
//点乘
double dot(const Point & a, const Point & b)
{
return a.x*b.x + a.y*b.y + a.z*b.z;
}
//判断四点共面
bool sameFace(const Point & a, const Point & b, const Point & c, const Point & d)
{
return sig(dot(b-a, cross(a, c, d))) == ;
}
//两点距离
double dis(const Point & a, const Point & b)
{
return sqrt(sqr(a.x-b.x) + sqr(a.y-b.y) + sqr(a.z-b.z));
}
int main()
{
int tcase,n,t=;
scanf("%d",&tcase);
while(tcase--)
{
scanf("%d",&n);
for(int i=; i<=n; i++)
{
scanf("%lf%lf%lf",&p[i].x,&p[i].y,&p[i].z);
}
int ans = ,ans1=;
for(int i=; i<=n; i++)
{
for(int j=i+; j<=n; j++) ///枚举对角线
{
int cnt = ;
for(int k=; k<=n; k++)
{
if(sig(dis(p[i],p[k])-dis(p[j],p[k]))==)
{
node[++cnt].idx = k;
node[cnt].dis = dis(p[i],p[k]);
}
}
for(int k=; k<=cnt; k++)
{
for(int l=k+; l<=cnt; l++)
{
if(sig(node[k].dis-node[l].dis)!=) continue;
if(sameFace(p[i],p[j],p[node[k].idx],p[node[l].idx])) continue;
ans++;
if(sig(dis(p[node[k].idx],p[node[l].idx])-node[k].dis)==&&sig(dis(p[i],p[j])-node[k].dis)==)
{
ans1++;
}
}
}
}
}
printf("Case #%d: %d\n",t++,ans/-ans1/);
}
}
 

hdu 5839(三维几何)的更多相关文章

  1. HDU 5839 Special Tetrahedron

    HDU 5839 Special Tetrahedron 题目链接http://acm.hdu.edu.cn/showproblem.php?pid=5839 Description Given n ...

  2. hdu 4617 Weapon【异面直线距离——基础三维几何】

    链接: http://acm.hdu.edu.cn/showproblem.php?pid=4617 Weapon Time Limit: 3000/1000 MS (Java/Others)     ...

  3. HDU 4617 Weapon(三维几何)

    Problem Description Doctor D. are researching for a horrific weapon. The muzzle of the weapon is a c ...

  4. HDU 5839 Special Tetrahedron (2016CCPC网络赛08) (暴力+剪枝)

    题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=5839 在一个三维坐标,给你n个点,问你有多少个四面体(4个点,6条边) 且满足至少四边相等 其余两边不 ...

  5. HDU 5839 Special Tetrahedron 计算几何

    Special Tetrahedron 题目连接: http://acm.hdu.edu.cn/showproblem.php?pid=5839 Description Given n points ...

  6. HDU 5839 Special Tetrahedron (计算几何)

    Special Tetrahedron 题目链接: http://acm.hdu.edu.cn/showproblem.php?pid=5839 Description Given n points ...

  7. HDU 4087 三维上的平移缩放旋转矩阵变化

    题目大意: 就是根据它给的程序的要求,不断平移,缩放,旋转三维的点,最后计算出点的位置 这里主要是要列出三种转换方式的齐次矩阵描述 平移translate tx ty tz1 0 0 00 1 0 0 ...

  8. HDU 3584 三维树状数组

    三维树状数组模版.优化不动了. #include <set> #include <map> #include <stack> #include <cmath& ...

  9. hdu 1140(三维)

    War on Weather Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)To ...

随机推荐

  1. HDU 4383 To The Moon 解题报告

    HDU 4383 To The Moon 题意翻译 已知一个长为\(n\)的序列\(a\),你需要进行下面的四种操作. C l r d 将区间\([l,r]\)中的数加上\(d\),同时时间加\(1\ ...

  2. oAuth2.0理解

    转自http://www.ruanyifeng.com/blog/2014/05/oauth_2_0.html 理解OAuth 2.0 作者: 阮一峰 日期: 2014年5月12日 OAuth是一个关 ...

  3. python基础----列表生成式、生成器表达式

    结论: 1.把列表解析的[]换成()得到的就是生成器表达式 2.列表解析与生成器表达式都是一种便利的编程方式,只不过生成器表达式更节省内存 3.Python不但使用迭代器协议,让for循环变得更加通用 ...

  4. 使用Hexo写博客

    首先,你需要搭建一个Hexo博客网站- 使用Hexo搭建GitHub博客(2018年Mac版) 原生方式新建文章 Hexo的项目结构是在网站根目录的source/_posts目录下存放你的博客文档,以 ...

  5. UESTC--1727

    原题链接:http://acm.uestc.edu.cn/problem.php?pid=1727 分析:用 l[i] 记录第 i 层楼有多少物品需要往上继续搬运,如果某层楼没有物品,但是更上面还有, ...

  6. 管理lnmp常用命令,lnmp重启,start|stop|reload|restart等命令

    LNMP状态管理命令: LNMP状态管理: /root/lnmp {start|stop|reload|restart|kill|status}Nginx状态管理:/etc/init.d/nginx ...

  7. 「Python-Django」Django中使用数据库的 9 个小技巧

    Django 中使用数据库的 9 个小技巧. 1. 过滤器聚合 在 Django 2.0 之前,如果你想得到“用户总数”.“活跃用户总数”等信息时,你不得不使用条件表达式. Django 2.0 中, ...

  8. 「HTML5」url、href、src区别

    一.URL的概念 统一资源定位符(或称统一资源定位器/定位地址.URL地址等,英语:Uniform Resource Locator,常缩写为URL),有时也被俗称为网页地址(网址).如同在网络上的门 ...

  9. 深入分析Java中的 == 和equals

    关于Java中的 == 和equals的解释请看这位博主的文章 :http://www.cnblogs.com/dolphin0520/p/3592500.html 以下是我对这篇文章的一些扩展. 对 ...

  10. 数据分析与展示---Numpy入门

    概括: 一:数据维度 (一)一维数据 (二)二维数据 (三)多维数据 (四)高维数据 二:Numpy的数组对象:ndarray (一)Numpy介绍 (二)N维数组对象ndarray (三)ndarr ...