Advertisement
Saleh127

UVA 10991 / Geometry - Cosine rule

Jun 18th, 2022
867
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 1.25 KB | None | 0 0
  1. /***
  2.  created: 2022-06-17-23.34.25
  3. ***/
  4.  
  5. #include <bits/stdc++.h>
  6. #include <ext/pb_ds/assoc_container.hpp>
  7. #include <ext/pb_ds/tree_policy.hpp>
  8. using namespace std;
  9. using namespace __gnu_pbds;
  10. template<typename U> using ordered_set=tree<U, null_type,less<U>,rb_tree_tag,tree_order_statistics_node_update>;
  11. #define ll long long
  12. #define test int tt; cin>>tt; for(int cs=1;cs<=tt;cs++)
  13. #define get_lost_idiot return 0
  14. #define nl '\n'
  15.  
  16. int main()
  17. {
  18.     ios_base::sync_with_stdio(0);
  19.     cin.tie(0);
  20.     cout.tie(0);
  21.  
  22.     test
  23.     {
  24.         double r1,r2,r3;
  25.  
  26.         cin>>r1>>r2>>r3;
  27.  
  28.         double a=r1+r2;
  29.  
  30.         double b=r2+r3;
  31.  
  32.         double c=r1+r3;
  33.  
  34.         double s=(a+b+c)/2.00;
  35.  
  36.         double trainglearea = sqrt(s*(s-a)*(s-b)*(s-c));
  37.  
  38.         double angle1 = acos(((b*b)+(c*c)-(a*a))/2.0/b/c);
  39.  
  40.         double sector1= (angle1*r3*r3) /2.00 ;
  41.  
  42.         double angle2 = acos(((a*a)+(c*c)-(b*b))/2.00/a/c);
  43.  
  44.         double sector2 = (angle2*r1*r1) /2.00 ;
  45.  
  46.         double angle3 = acos(((a*a)+(b*b)-(c*c))/2.00/a/b);
  47.  
  48.         double sector3 = (angle3*r2*r2) /2.00 ;
  49.  
  50.         double ans = trainglearea - sector1 - sector2 - sector3;
  51.  
  52.         cout<<fixed<<setprecision(6)<<ans<<nl;
  53.     }
  54.  
  55.  
  56.  
  57.     get_lost_idiot;
  58. }
  59.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement