Cod sursa(job #2829239)

Utilizator cezar_titianuTitianu Cezar cezar_titianu Data 8 ianuarie 2022 13:56:07
Problema Aria Scor 70
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.51 kb
#include <fstream>
#include <cmath>
#include <iomanip>

int main() {
	std::ifstream fin("aria.in");
	std::ofstream fout("aria.out");
	int nrn;
	double posx, posy, antx, anty, fstx, fsty;
	double ans = 0;
	fin >> nrn;
	fin >> antx >> anty;
	fstx = antx;
	fsty = anty;
	for (int index = 1; index < nrn; index++) {
		fin >> posx >> posy;
		ans += (posy * antx - posx * anty) / 2;
		antx = posx;
		anty = posy;
	}
	ans += (fsty * antx - fstx * anty) / 2;
	fout << std::fixed << std::setprecision(5) << ans;
}