fork(2) download
  1. #include <iostream>
  2. #include <vector>
  3. #include <iomanip>
  4.  
  5.  
  6.  
  7. using namespace std;
  8. double bez(double x)
  9. {
  10. if(x<0)
  11. {
  12. return x*-1;
  13. }
  14. else
  15. {
  16. return x;
  17. }
  18. }
  19.  
  20. double Pole(double x,double y,double x1,double y1)
  21. {
  22. double p;
  23. p=((x*y1)-(x1*y))/2;
  24. return bez(p);
  25. }
  26.  
  27.  
  28. int main()
  29. {
  30.  
  31. int ile,a,b,c,d;
  32. double pole,p2,x=-1;
  33. vector <double> wx;
  34. vector <double> wy;
  35.  
  36. cin>>ile;
  37. for(int i=0;i<ile*2;i++)
  38. {
  39. x+=2;
  40. cin>>a;
  41. cin>>b;
  42. cin>>c;
  43. cin>>d;
  44. wx.push_back(c-a);
  45. wy.push_back(d-b);
  46. cin>>c;
  47. cin>>d;
  48. wx.push_back(c-a);
  49. wy.push_back(d-b);
  50. pole=Pole(wx[x-1],wy[x-1],wx[x],wy[x]);
  51. while((c!=a)||(d!=b))
  52. {
  53. x++;
  54. cin>>c;
  55. cin>>d;
  56. wx.push_back(c-a);
  57. wy.push_back(d-b);
  58. if((wy[x]/wx[x])>(wy[x-1]/wx[x-1])&&wx[x]>=0||(wy[x]/wx[x])<(wy[x-1]/wx[x-1])&&wx[x]<0)
  59. {
  60. pole+=Pole(wy[x],wx[x],wy[x-1],wx[x-1]);;
  61. }
  62. else
  63. {
  64. pole-=Pole(wy[x],wx[x],wy[x-1],wx[x-1]);
  65. }
  66. }
  67. pole=bez(pole);
  68. if(i%2==0)
  69. {
  70. p2=pole;
  71.  
  72. }
  73. else
  74. {
  75. cout<<setprecision(1000);
  76. if(pole>p2)
  77. cout<<(p2*10)+(pole-p2)*6<<endl;
  78. else
  79. cout<<(pole*10)+(p2-pole)*6<<endl;
  80. }
  81.  
  82. }
  83. return 0;
  84. }
Success #stdin #stdout 0s 15232KB
stdin
Standard input is empty
stdout
Standard output is empty