Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <cstdio>
- #include <cmath>
- #include <algorithm>
- using namespace std;
- typedef long long ll;
- #define FILE_NAME "area"
- const int N = 100100;
- pair<int, int> a[N];
- int main()
- {
- freopen(FILE_NAME".in", "r", stdin);
- freopen(FILE_NAME".out", "w", stdout);
- int n;
- scanf("%d", &n);
- for (int i = 0; i < n; ++i)
- scanf("%d%d", &a[i].first, &a[i].second);
- a[n] = a[0];
- ll sum = 0;
- for (int i = 1; i <= n; ++i)
- sum += (a[i].first - a[i - 1].first) * (a[i].second + a[i - 1].second);
- if (sum < 0) sum = -sum;
- printf("%.12lf\n", 0.5 * sum);
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment