Guest User

100168 C

a guest
Jan 28th, 2021
48
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.59 KB | None | 0 0
  1. #include <cstdio>
  2. #include <cmath>
  3. #include <algorithm>
  4.  
  5. using namespace std;
  6.  
  7. typedef long long ll;
  8.  
  9. #define FILE_NAME "area"
  10.  
  11. const int N = 100100;
  12.  
  13. pair<int, int> a[N];
  14.  
  15. int main()
  16. {
  17.     freopen(FILE_NAME".in", "r", stdin);
  18.     freopen(FILE_NAME".out", "w", stdout);
  19.  
  20.     int n;
  21.     scanf("%d", &n);
  22.     for (int i = 0; i < n; ++i)
  23.         scanf("%d%d", &a[i].first, &a[i].second);
  24.     a[n] = a[0];
  25.     ll sum = 0;
  26.     for (int i = 1; i <= n; ++i)
  27.         sum += (a[i].first - a[i - 1].first) * (a[i].second + a[i - 1].second);
  28.     if (sum < 0) sum = -sum;
  29.     printf("%.12lf\n", 0.5 * sum);
  30.  
  31.     return 0;
  32. }
Advertisement
Add Comment
Please, Sign In to add comment