Saleh127

Light oj(LO) 1146

Feb 24th, 2021
192
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.24 KB | None | 0 0
  1. #include <bits/stdc++.h>
  2. using namespace std;
  3. #define ll long long
  4. #define test int t; cin>>t; for(int cs=1;cs<=t;cs++)
  5.  
  6. struct point
  7. {
  8. double x,y;
  9. };
  10.  
  11. double dis(point a,point b)
  12. {
  13. return sqrt((a.x-b.x)*(a.x-b.x)+(a.y-b.y)*(a.y-b.y));
  14. }
  15.  
  16. int main()
  17. {
  18. ios_base::sync_with_stdio(0);
  19. cin.tie(0);cout.tie(0);
  20.  
  21.  
  22. test
  23. {
  24.  
  25. point z[5];
  26.  
  27. ll i,j,k,l=100;
  28.  
  29. for(i=0;i<4;i++)
  30. {
  31. cin>>z[i].x>>z[i].y;
  32. }
  33.  
  34. double ac,bd;
  35.  
  36. while(l--)
  37. {
  38. point a,b,c,d;
  39.  
  40. a.x=(2*z[0].x+z[1].x)/3.00;
  41. a.y=(2*z[0].y+z[1].y)/3.00;
  42.  
  43. c.x=(2*z[2].x+z[3].x)/3.00;
  44. c.y=(2*z[2].y+z[3].y)/3.00;
  45.  
  46. b.x=(z[0].x+2*z[1].x)/3.00;
  47. b.y=(z[0].y+2*z[1].y)/3.00;
  48.  
  49. d.x=(z[2].x+2*z[3].x)/3.00;
  50. d.y=(z[2].y+2*z[3].y)/3.00;
  51.  
  52.  
  53. ac=dis(a,c);
  54. bd=dis(b,d);
  55.  
  56. if(ac>bd)
  57. {
  58. z[0]=a;
  59. z[2]=c;
  60. }
  61. else
  62. {
  63. z[1]=b;
  64. z[3]=d;
  65. }
  66.  
  67. }
  68. cout<<"Case "<<cs<<": ";
  69. cout<<fixed<<setprecision(10)<<(ac+bd)/2.00<<endl;
  70. }
  71. return 0;
  72. }
  73.  
Advertisement
Add Comment
Please, Sign In to add comment