fork(2) download
  1. #include <iostream>
  2. #include <iomanip>
  3. #include <cmath>
  4. using namespace std;
  5.  
  6. int main() {
  7. int n, x1, x2, y1, y2, x, y;
  8. double sum=0;
  9. cin >> n >> x >> y;
  10. x1=x;
  11. y1=y;
  12. for (int i=0; i<(n-1); i++) {
  13. cin >> x2 >> y2;
  14. sum=sum+(x1+x2)*(y2-y1);
  15. x1=x2;
  16. y1=y2;
  17. }
  18. sum=sum+(x+x2)*(y-y2);
  19. cout << fixed << setprecision(3) << abs(sum) / 2 << endl;
  20. return 0;
  21. }
Success #stdin #stdout 0s 3416KB
stdin
4
-1000 500
-500 1000
2 10
35 60
stdout
339865.000