1 条题解
-
0
#include <bits/stdc++.h> using namespace std; const int N = 1e3 + 10; struct Point { double x, y; Point() {} Point(double a, double b) : x(a), y(b) {} void input() { scanf("%lf%lf", &x, &y); } friend Point operator-(Point a, Point b) { return {a.x - b.x, a.y - b.y}; } friend double det(Point a, Point b) { return a.x * b.y - a.y * b.x; } } P[N]; int main() { int n; scanf("%d", &n); for (int i = 1; i <= n; i++) P[i].input(); double ans = 0; for (int i = 3; i <= n; i++) ans += det(P[i-1] - P[1], P[i] - P[1]); if (ans < 0) ans = -ans; printf("%.4lf\n", ans / 2.0); return 0; }
- 1
信息
- ID
- 435
- 时间
- 1000ms
- 内存
- 128MiB
- 难度
- 5
- 标签
- 递交数
- 58
- 已通过
- 23
- 上传者