HDU 5206 Four Inages Strategy
传送们:http://acm.hdu.edu.cn/showproblem.php?pid=5206 题目翻译 空间里四个点,看看是否能组成正方形。 题解 判定定理:四条边相等 + 一个直角 代码
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 |
#include<cstdio> #define LL long long using namespace std; const int Maxn=5; struct Point{ int x,y,z; Point(){} Point(int x0,int y0,int z0){ x=x0; y=y0; z=z0; } inline void read(){ scanf("%d%d%d",&x,&y,&z); } Point operator - (const Point &b){ return Point(x-b.x,y-b.y,z-b.z); } LL operator * (const Point &b){ return x*b.x+y*b.y+z*b.z; } }; Point poi[Maxn+5]; inline LL sqr(LL x){ return x*x; } inline LL dist(int x,int y){ Point a=poi[x]; Point b=poi[y]; return sqr(a.x-b.x)+sqr(a.y-b.y)+sqr(a.z-b.z); } inline void solve(int T){ for (int i=1;i<=4;i++) poi[i].read(); for (int i=1;i<=4;i++){ for (int j=i+1;j<=4;j++){ for (int p=1;p<=4;p++){ for (int q=1;q<=4;q++){ if (p==q) continue; if (p==i || p==j) continue; if (q==i || q==j) continue; if (!(dist(i,p)==dist(i,q) && dist(j,p)==dist(j,q) && dist(i,p)==dist(j,p))) continue; if ((poi[p]-poi[i])*(poi[q]-poi[i])!=0) continue; printf("Case #%d: Yes\n",T); return; } } } } printf("Case #%d: No\n",T); } int main(){ int T=0; while(scanf("%d",&T)!=EOF){ for (int i=1;i<=T;i++){ solve(i); } } return 0; } |