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

2 3 5 2 3 3 5 4 2 3
1 5 1 3 5 0 3 2 5 1 6 2 4 3 6 3 6 4 7 4 7 1 6 1 6 0 8 0 8 5 1 5
stdout
23
139