Cod sursa(job #1801755)
| Utilizator | Data | 9 noiembrie 2016 16:40:15 | |
|---|---|---|---|
| Problema | Aria | Scor | 0 |
| Compilator | cpp | Status | done |
| Runda | Arhiva educationala | Marime | 0.58 kb |
#include <fstream>
#include <cmath>
using namespace std;
ifstream fin("aria.in");
ofstream fout("aria.out");
struct vector2{
double x,y;
};
int arie(vector2 a,vector2 b,vector2 c)
{
return a.x * b.y + a.y * c.x + b.x * c.y - a.x * c.y - a.y * b.x - b.y * c.x;
}
int n;
double A;
vector2 Or;
vector2 lst,act;
int main()
{
fin>>n;
fin>>Or.x >>Or.y;
fin>>lst.x>>lst.y;
for(int i=1;i<=n;i++)
{
fin>>act.x>>act.y;
A+= arie(Or,lst,act);
lst = act;
}
fout<<abs(A) / 2<<'\n';
return 0;
}
