#include <stdio.h>
double area(int x1, int y1, int x2, int y2, int x3, int y3)
{
double res = (x1*y2 + x2*y3 + x3*y1 - x2*y1 - x3*y2 - x1*y3)/(double)2;
if (res < 0)
res = -res;
return res;
}
int main(void)
{
int x[2000] = { 0 };
int y[2000] = { 0 };
int N = 0,count = 0;
double sum = 0;
scanf("%d", &N);
for (int i = 0; i < N; i++)
{
scanf("%d%d", &x[i], &y[i]);
}
for (int a = 0; a < N-2;a++)
{
for (int b = a+1; b < N - 1;b++)
{
for (int c = b+1; c < N;c++)
{
sum += area(x[a], y[a], x[b], y[b], x[c], y[c]);
count++;
}
}
}
printf("%.1200f\n", sum/count);
return 0;
}
# |
결과 |
실행 시간 |
메모리 |
Grader output |
1 |
Correct |
0 ms |
1084 KB |
Output is correct |
2 |
Correct |
0 ms |
1084 KB |
Output is correct |
3 |
Incorrect |
0 ms |
1084 KB |
Output isn't correct |
4 |
Halted |
0 ms |
0 KB |
- |