fork download
  1. //Bismillahir Rahmanir Rahim
  2. /******Harun Or Rashid******/
  3. /***********Template Starts Here***********/
  4. #include<iostream>
  5. #include<cstdio>
  6. #include<cstring>
  7. #include<cmath>
  8. #include<cctype>
  9. #include<cstdlib>
  10. #include<cassert>
  11. #include<string>
  12. #include<vector>
  13. #include<set>
  14. #include<stack>
  15. #include<queue>
  16. #include<map>
  17. #include<algorithm>
  18. using namespace std;
  19.  
  20. #define MEM(a,b) memset(a,b,sizeof(a))
  21. #define CLR(a) memset(a,0,sizeof(a))
  22. #define MAX(a,b) ((a)>(b)?(a):(b))
  23. #define MIN(a,b) ((a)>(b)?(b):(a))
  24. #define ABS(a) ((a)>0? (a):(-(a)))
  25. #define SQ(a) ((a)*(a))
  26. #define SZ(a) (int)a.size()
  27. #define FORN(i,n) for(i=1;i<=n;i++)
  28. #define FORAB(i,a,b) for(i=a;i<=b;i++)
  29. #define ALL(V) V.begin(),V.end()
  30. #define pb(a) push_back(a)
  31. #define pr(a) cout<<a<<endl
  32. #define SQR(a) ((a)*(a))
  33. #define pf printf
  34. #define sf scanf
  35. #define swap(a,b) (a ^= b, b ^= a, a ^= b)
  36. #define PI acos(-1)
  37. #define x first
  38. #define y second
  39. #define eps 1e-7
  40.  
  41. typedef int D;
  42. typedef long long int LLD;
  43. typedef unsigned long long int LLU;
  44. typedef vector<D> VI;
  45. typedef set<D> SI;
  46. typedef vector<D>::iterator Viti;
  47.  
  48. /***********Template Ends Here***********/
  49.  
  50. int main()
  51. {
  52. int T,i;
  53. double m,a,b,c,d,S,TA,h,A,x,y,z,n,l,r;
  54. cin>>T;
  55. for(i=1; i<=T; i++)
  56. {
  57. cin>>a>>b>>c>>d;
  58. m=a-b;
  59. S=(m+c+d)/2.;
  60. TA=sqrt(S*(S-m)*(S-c)*(S-d));
  61. h=(TA/m)*2;
  62. A=((a+b)/2/2)*h;
  63. x=m;
  64. y=2*b*h;
  65. z=-(2*A*h);
  66. n=(-y+sqrt(y*y-4*x*z))/(2*x);
  67. l=c*n/h;
  68. r=d*n/h;
  69. l=c-l;
  70. r=d-r;
  71. printf("Land #%d: %lf %lf\n",i,l,r);
  72. }
  73. return 0;
  74. }
  75.  
  76.  
Success #stdin #stdout 0s 3480KB
stdin
2

15 12 9 10

12 6 5 5
stdout
Land #1: 4.250767 4.723074
Land #2: 2.094306 2.094306