Cod sursa(job #2921948)

Utilizator alt_contStefan alt_cont Data 2 septembrie 2022 16:19:25
Problema Aria Scor 100
Compilator cpp-32 Status done
Runda Arhiva educationala Marime 0.81 kb
#include <fstream>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stack>
#include <iomanip>
#define epsilon 1e-12

using namespace std;

typedef pair<double,double> Point;
Point points[150000];

Point operator-(Point a, Point b){
	return Point(a.first - b.first, a.second - b.second);
}

double angle(Point a){
	return atan2(a.first, a.second);
}

double det(Point a, Point b){
	return (a.first * b.second - a.second * b.first)/2;
}

int main(){
	ifstream fin("aria.in");
	ofstream fout("aria.out");
	int n;
	fin >> n;
	for(int i = 0; i < n; ++i){
		fin >> points[i].first >> points[i].second;
	}

	double area = 0;

	for(int i=1; i <= n - 2; ++i){
		area += det(points[i] - points[0], points[i + 1] - points[0]);
	}

	fout << fixed << setprecision(6) << fabs(area);
}