标签:
题目描述:如标题
思路:一比一比根号二咯
1 #include <algorithm> 2 #include <iostream> 3 #include <string> 4 using namespace std; 5 6 const int N = 4; 7 8 struct Node 9 { 10 int x, y, z; 11 } node[N]; 12 13 inline long long square( int k ) 14 { 15 return ( long long ) k * k; 16 } 17 18 long long list[N]; 19 20 long long dis( Node a, Node b ) 21 { 22 return square( a.x - b.x ) + square( a.y - b.y ) + square( a.z - b.z ); 23 } 24 25 bool solve() 26 { 27 for ( int i = 0; i < 4; i++ ) 28 { 29 int cnt = 0; 30 for ( int j = 0; j < 4; j++ ) 31 { 32 if ( i == j ) continue; 33 list[cnt++] = dis( node[i], node[j] ); 34 } 35 sort( list, list + cnt ); 36 if ( list[0] == list[1] && list[1] * 2 == list[2] ) {} 37 else return false; 38 } 39 return true; 40 } 41 42 int main () 43 { 44 int t; 45 cin >> t; 46 for ( int _case = 1; _case <= t; _case++ ) 47 { 48 for ( int i = 0; i < 4; i++ ) 49 { 50 cin >> node[i].x >> node[i].y >> node[i].z; 51 } 52 cout << "Case #" << _case << ": " << ( solve() ? "Yes" : "No" ) << endl; 53 } 54 return 0; 55 }
其实还有许多方法,有时间补上。
标签:
原文地址:http://www.cnblogs.com/huoxiayu/p/4438460.html