Cod sursa(job #2444149)

Utilizator Alex18maiAlex Enache Alex18mai Data 30 iulie 2019 13:49:17
Problema Aria Scor 70
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.6 kb
#include <fstream>
#include <iomanip>

using namespace std;

ifstream cin("aria.in");
ofstream cout("aria.out");

pair<double, double> pct[100100];

double det(pair<double, double> one, pair<double, double> two) {
	return (one.first * two.second - one.second * two.first) / 2;
}

int main() {
	int n;
	cin >> n;
	double sum = 0;
	for (int i = 1; i <= n; i++) {
		cin >> pct[i].first >> pct[i].second;
	}
	pct[0].first = pct[n].first;
	pct[0].second = pct[n].second;
	for (int i = 1; i <= n; i++) {
		sum += det(pct[i - 1], pct[i]);
	}
	cout << setprecision(5) << fixed << sum;
	return 0;
}