标签:
input | output |
---|---|
0 0 12 12 0 0 10 0 10 10 |
19.71 |
1 /** 2 Create By yzx - stupidboy 3 */ 4 #include <cstdio> 5 #include <cstring> 6 #include <cstdlib> 7 #include <cmath> 8 #include <deque> 9 #include <vector> 10 #include <queue> 11 #include <iostream> 12 #include <algorithm> 13 #include <map> 14 #include <set> 15 #include <ctime> 16 #include <iomanip> 17 using namespace std; 18 typedef long long LL; 19 typedef double DB; 20 #define MIT (2147483647) 21 #define INF (1000000001) 22 #define MLL (1000000000000000001LL) 23 #define sz(x) ((int) (x).size()) 24 #define clr(x, y) memset(x, y, sizeof(x)) 25 #define puf push_front 26 #define pub push_back 27 #define pof pop_front 28 #define pob pop_back 29 #define ft first 30 #define sd second 31 #define mk make_pair 32 33 inline int Getint() 34 { 35 int Ret = 0; 36 char Ch = ‘ ‘; 37 bool Flag = 0; 38 while(!(Ch >= ‘0‘ && Ch <= ‘9‘)) 39 { 40 if(Ch == ‘-‘) Flag ^= 1; 41 Ch = getchar(); 42 } 43 while(Ch >= ‘0‘ && Ch <= ‘9‘) 44 { 45 Ret = Ret * 10 + Ch - ‘0‘; 46 Ch = getchar(); 47 } 48 return Flag ? -Ret : Ret; 49 } 50 51 const DB EPS = 1e-7; 52 struct Point 53 { 54 DB x, y, z; 55 inline void Read() 56 { 57 cin >> x >> y >> z; 58 } 59 } a, b, c; 60 DB r; 61 62 inline void Input() 63 { 64 a.Read(); 65 b.Read(); 66 c.Read(); 67 cin >> r; 68 } 69 70 inline DB Sqr(DB x) 71 { 72 return x * x; 73 } 74 75 inline DB Dist(Point a, Point b) 76 { 77 return sqrt(Sqr(a.x - b.x) + Sqr(a.y - b.y) + Sqr(a.z - b.z)); 78 } 79 80 inline void Solve() 81 { 82 DB ans = 0.0; 83 84 DB ab = Dist(a, b), 85 ac = Dist(a, c), 86 bc = Dist(b, c); 87 88 DB angle = 89 acos((Sqr(ac) + Sqr(bc) - Sqr(ab)) / (2.0 * ac * bc)) - 90 acos(r / ac) - acos(r/ bc); 91 if(angle <= EPS) 92 { 93 printf("%.2lf\n", ab); 94 return; 95 } 96 97 ans += sqrt(Sqr(ac) - Sqr(r)); 98 ans += sqrt(Sqr(bc) - Sqr(r)); 99 ans += angle * r; 100 101 printf("%.2lf\n", ans); 102 } 103 104 int main() 105 { 106 freopen("g.in", "r", stdin); 107 Input(); 108 Solve(); 109 return 0; 110 }
标签:
原文地址:http://www.cnblogs.com/StupidBoy/p/5076845.html