Advertisement
erfanul007

UVa 10522

Apr 8th, 2021
671
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 7.86 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. // #include <iostream>
  3. // #include <cstdio>
  4. // #include <cstdlib>
  5. // #include <algorithm>
  6. // #include <cmath>
  7. // #include <vector>
  8. // #include <set>
  9. // #include <map>
  10. // #include <queue>
  11. // #include <stack>
  12. // #include <ctime>
  13. // #include <cassert>
  14. // #include <complex>
  15. // #include <string>
  16. // #include <cstring>
  17. // #include <bitset>
  18. using namespace std;
  19.  
  20. // #pragma GCC optimize("Ofast,no-stack-protector")
  21. // #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
  22. // #pragma GCC optimize("unroll-loops")
  23.  
  24. #define ll              long long int
  25. #define vi              vector< int >
  26. #define vll             vector< ll >
  27.  
  28. #define sc              scanf
  29. #define pf              printf
  30. #define cspf(i)         pf("Case %d: ", i)
  31. #define spc             pf(" ")
  32. #define line            pf("\n")
  33.  
  34. #define ff              first
  35. #define ss              second
  36. #define mp              make_pair
  37. #define pb              push_back
  38. #define ppb             pop_back
  39. #define tp(v,j)         get<j>(v)
  40. #define Log(b,x)        (log(x)/log(b))
  41.  
  42. #define FOR(i,x,y)      for(int i = int(x); i < int(y); i++)
  43. #define ROF(i,x,y)      for(int i = int(x)-1; i >= int(y); i--)
  44. #define clr(arr,x)      memset(arr, x, sizeof arr)
  45. #define vout(v,sz)      for(int w=0;w<sz;w++){if(w) spc; cout<<v[w];}
  46. #define all(v)          v.begin(), v.end()
  47. #define rall(v)         v.rbegin(), v.rend()
  48. #define unq(v)          sort(all(v)),(v).resize(unique(all(v))-v.begin())
  49. #define fastIO          ios::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr)
  50.  
  51. #define sc1(x)          sc("%d",&x);
  52. #define sc2(x,y)        sc("%d %d", &x, &y)
  53. #define sc3(x,y,z)      sc("%d %d %d", &x, &y, &z)
  54. #define scl1(x)         sc("%lld",&x);
  55. #define scl2(x,y)       sc("%lld %lld", &x, &y)
  56. #define scf1(x)         sc("%lf",&x);
  57. #define scf2(x,y)       sc("%lf %lf", &x, &y)
  58.  
  59. #define pf1(x)          pf("%d",x);
  60. #define pf2(x,y)        pf("%d %d", x, y)
  61. #define pfl1(x)         pf("%lld",x);
  62. #define pfl2(x,y)       pf("%lld %lld", x, y)
  63.  
  64. #define MOD             (int)(998244353)
  65. #define MaxN            100000
  66. #define inf             0x3f3f3f3f
  67. #define PI              acos(-1.0)  // 3.1415926535897932
  68. #define eps             1e-9
  69.  
  70. template <class T> inline T bigMod(T p,T e,T M){T ret=1; for(;e>0;e>>=1){ if(e&1) ret=(ret*p)%M; p=(p*p)%M;} return (T)ret;}
  71. template <class T> inline T modInverse(T a,T M){return bigMod(a,M-2,M);}
  72. template <class T> inline T gcd(T a,T b){if(b==0)return a;return gcd(b,a%b);}
  73. template <class T> inline T lcm(T a,T b) {a=abs(a);b=abs(b); return (a/gcd(a,b))*b;}
  74.  
  75. int dx[] = { 1,-1, 0, 0};                //graph moves
  76. int dy[] = { 0, 0, 1,-1};               //graph moves
  77.  
  78. struct PT{
  79.     double x, y;
  80.     void scan(){ scanf("%lf %lf",&x,&y);}
  81. };
  82.  
  83. double SQ(double x){ return x*x;}
  84.  
  85. double Dis(PT a,PT b){ return SQ(a.x - b.x) + SQ(a.y - b.y);}
  86.  
  87. double absDis(PT a,PT b){ return sqrt(Dis(a,b));}
  88.  
  89. /*two vector lines Dot product*/
  90. int Dot(PT a,PT b){ return a.x*b.x + a.y*b.y;}
  91.  
  92. /*two vector lines Cross product*/
  93. int Cross(PT a,PT b){ return a.x*b.y - b.x*a.y;}
  94.  
  95. /*convert degree to radian*/
  96. double toRadian(double x){ return (x*(PI/180.0));}
  97.  
  98. /*convert radian to degree*/
  99. double toDegree(double x){ return (x*(180.0/PI));}
  100.  
  101. /*two point's vector line*/
  102. PT vect(PT a,PT b){ return {a.x-b.x, a.y-b.y};}
  103.  
  104. /*convert a coordinate p from cartesian to polar
  105. r = sqrt(x*x + y*y)
  106. theta = atan(y/x) [in radian]*/
  107. PT toPolar(PT p){
  108.     return {sqrt(SQ(p.x)+SQ(p.y)), atan(p.y/p.x)};
  109. }
  110.  
  111. /*convert a coordinate p from polar to cartesian
  112. theta must be radian
  113. x = r * cos(theta)
  114. y = r * sin(theta)*/
  115. PT toCartesian(PT a){
  116.     return {a.x * cos(a.y), a.x * sin(a.y)};
  117. }
  118.  
  119. /*divide line ab into m:n and return midpoint*/
  120. /*For 3D add the z part same as x and y*/
  121. PT divideLine(PT a, PT b, double m, double n){
  122.     return {(a.x * m + b.x * n)/(m+n),
  123.         (a.y * m + b.y * n)/(m+n)};
  124. }
  125.  
  126. /*line ab to point c
  127. 0 => if ab and c coliner
  128. + => clockwise
  129. - => anticlockwise
  130. */
  131. int orientation(PT a, PT b, PT c)
  132. {
  133.     return (b.y-a.y)*(c.x-b.x)-(b.x-a.x)*(c.y-b.y);
  134. }
  135.  
  136. /*line ab and line cd is parrallel if ab X cd = 0 */
  137. bool ifParallel(PT a,PT b,PT c,PT d)
  138. {
  139.     if(Cross(vect(a,b),vect(c,d)) != 0) // for double abs(val) > eps
  140.         return false;
  141.     return true;
  142. }
  143.  
  144. /*line ab and line cd is perpendicular if ab . cd = 0 */
  145. bool ifPerpendicular(PT a,PT b,PT c,PT d)
  146. {
  147.     if(Dot(vect(a,b),vect(c,d)) != 0) // for double abs(val) > eps
  148.         return false;
  149.     return true;
  150. }
  151.  
  152. /*Area*/
  153.  
  154. double heronTriangle(double a, double b, double c){
  155.     double s = (a + b + c) / 2.0;
  156.     if(s - a < 0) return -1;
  157.     if(s - b < 0) return -1;
  158.     if(s - c < 0) return -1;
  159.     return sqrt(s * (s - a) * (s - b) * (s - c));
  160. }
  161.  
  162. double mdedianTriangle(double a, double b, double c){
  163.     double s = (a + b + c) / 2.0;
  164.     if(s - a < 0) return -1;
  165.     if(s - b < 0) return -1;
  166.     if(s - c < 0) return -1;
  167.     return (4.0 / 3.0 ) * sqrt(s * (s - a) * (s - b) * (s - c));
  168. }
  169.  
  170. double trapeziumArea(double a, double b, double h){
  171.     return (a + b) * h / 2.0;
  172. }
  173.  
  174. ///Area of irregular polygon
  175. double AreaOfPolygon(int n,PT a[])
  176. {
  177.     double area = 0.0;
  178.     for(int i=1;i<n;i++){
  179.         area+=(a[i-1].x*a[i].y-a[i].x*a[i-1].y);
  180.     }
  181.     area+=(a[n-1].x*a[0].y-a[0].x*a[n-1].y);
  182.     return area/2.0;
  183. }
  184.  
  185. /*volumn*/
  186.  
  187. double coneVolume(double r, double h){
  188.     return PI * r * r * h / 3.0;
  189. }
  190.  
  191. double CircumcircleR(double a, double b, double c){
  192.     if(a + b + c < eps) return 0;
  193.     return (a * b * c) / sqrt((a + b + c) * (b + c - a) * (c + a - b) * (a + b - c));
  194. }
  195.  
  196. double IncircleR(double a, double b, double c){
  197.     if(a + b + c < eps) return 0;
  198.     return 2.0 * heronTriangle(a, b, c) / (a + b + c);
  199. }
  200.  
  201. bool insideRectangle(PT p, PT a, PT c){
  202.     if(p.x < a.x or p.x > c.x) return false;
  203.     if(p.y < a.y or p.y > c.y) return false;
  204.     return true;
  205. }
  206.  
  207. /*checking shapes*/
  208.  
  209. bool isSquare(PT *a){
  210.     if(abs(Dis(a[0], a[1]) - Dis(a[1], a[2])) > eps
  211.         or abs(Dis(a[1], a[2]) - Dis(a[2], a[3])) > eps
  212.         or abs(Dis(a[2], a[3]) - Dis(a[3], a[0])) > eps)
  213.         return false;
  214.     if(!ifPerpendicular(a[0], a[1], a[1], a[2])) return false;
  215.     return true;
  216. }
  217.  
  218. bool isRectangle(PT *a){
  219.     if(abs(Dis(a[0], a[1]) - Dis(a[3], a[2])) > eps
  220.         or abs(Dis(a[1], a[2]) - Dis(a[0], a[3])) > eps)
  221.         return false;
  222.     if(!ifPerpendicular(a[0], a[1], a[1], a[2])) return false;
  223.     return true;
  224. }
  225.  
  226. bool isRombus(PT *a){
  227.     if(abs(Dis(a[0], a[1]) - Dis(a[1], a[2])) > eps
  228.         or abs(Dis(a[1], a[2]) - Dis(a[2], a[3])) > eps
  229.         or abs(Dis(a[2], a[3]) - Dis(a[3], a[0])) > eps)
  230.         return false;
  231.     return true;
  232. }
  233.  
  234. bool isParallelogram(PT *a){
  235.     if(abs(Dis(a[0], a[1]) - Dis(a[3], a[2])) > eps
  236.         or abs(Dis(a[1], a[2]) - Dis(a[0], a[3])) > eps)
  237.         return false;
  238.     return true;
  239. }
  240.  
  241. bool isTrapezium(PT *a){
  242.     if(!ifParallel(a[0], a[1], a[3], a[2])
  243.         and !ifParallel(a[1], a[2], a[0], a[3])) return false;
  244.     return true;
  245. }
  246.  
  247.  
  248. PT f; //init first coordinate
  249. //for clockwise sorting
  250. bool ClockCmp(PT &a,PT &b){ return (f.x-a.x)*(f.y-b.y)<(f.x-b.x)*(f.y-a.y);}
  251.  
  252. //for anti-clockwise sorting
  253. bool AClockCmp(PT &a,PT &b){ return (f.x-a.x)*(f.y-b.y)>(f.x-b.x)*(f.y-a.y);}
  254.  
  255. int main()
  256. {
  257.     #ifndef ONLINE_JUDGE
  258.         clock_t tStart = clock();
  259.         freopen("input.txt", "r", stdin);
  260.         freopen("output.txt", "w", stdout);
  261.     #endif
  262.  
  263.     int t, ca=0; sc1(t);
  264.  
  265.     while(1){
  266.         if(ca >= t) break;
  267.         double ha, hb, hc; sc("%lf %lf %lf", &ha, &hb, &hc);
  268.         double ab = ha * hb, bc = hb * hc, ac = hc * ha;
  269.         if((ab + eps > bc + ac) || (bc + eps > ab + ac) || (ac + eps > ab + bc)){
  270.             ca++;
  271.             pf("These are invalid inputs!\n", ca);
  272.             continue;
  273.         }
  274.         double ans = (SQ(ha) * SQ(hb) * SQ(hc))/sqrt((ab + bc + ac) * (-ab + bc + ac) * (-bc + ab + ac) * (-ac + ab + bc));
  275.         printf("%.3f\n", ans);
  276.     }
  277.  
  278.     #ifndef ONLINE_JUDGE
  279.         fprintf(stderr, "\n>> Runtime: %.10fs\n", (double) (clock() - tStart) / CLOCKS_PER_SEC);
  280.     #endif
  281.  
  282.     return 0;
  283. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement