fork download
  1. #include <algorithm>
  2. #include <cstdio>
  3. #include <stdint.h>
  4.  
  5. using namespace std;
  6.  
  7. struct point
  8. {
  9. int x, y;
  10.  
  11. bool top (void) const
  12. {
  13. return y > 0 || (y == 0 && x > 0);
  14. }
  15.  
  16. bool operator < (point const & other) const
  17. {
  18. if (top () != other.top ())
  19. {
  20. return top () > other.top ();
  21. }
  22. return (int64_t) x * other.y < (int64_t) y * other.x;
  23. }
  24. };
  25.  
  26. int main (void)
  27. {
  28. int n;
  29. while (scanf (" %d", &n) != EOF)
  30. {
  31. int m = n - 1;
  32. point b [n];
  33. for (int i = 0; i < n; i++)
  34. {
  35. scanf (" %d %d", &b[i].x, &b[i].y);
  36. }
  37.  
  38. double res = 0.0;
  39. for (int i = 0; i < n; i++)
  40. {
  41. point a [m * 2];
  42. for (int j = 0; j < n; j++)
  43. {
  44. if (j != i)
  45. {
  46. a[j - (j > i)].x = b[j].x - b[i].x;
  47. a[j - (j > i)].y = b[j].y - b[i].y;
  48. }
  49. }
  50. sort (a, a + m);
  51. for (int j = 0; j < m; j++)
  52. {
  53. a[j + m].x = a[j].x;
  54. a[j + m].y = a[j].y;
  55. }
  56.  
  57. double sumx = a[0].x;
  58. double sumy = a[0].y;
  59. int k = 1;
  60. for (int j = 0; j < m; j++)
  61. {
  62. sumx -= a[j].x;
  63. sumy -= a[j].y;
  64. while (((int64_t) a[j].x * a[k].y <
  65. (int64_t) a[j].y * a[k].x) ||
  66. j == k)
  67. {
  68. sumx += a[k].x;
  69. sumy += a[k].y;
  70. k++;
  71. }
  72. res += a[j].y * sumx - a[j].x * sumy;
  73. }
  74. }
  75.  
  76. res /= n;
  77. res /= (n - 1);
  78. res /= (n - 2);
  79. printf ("%.20lf\n", res);
  80. }
  81. return 0;
  82. }
  83.  
Success #stdin #stdout 0.47s 2860KB
stdin
2000
stdout
6673906517063116.00000000000000000000