Mai intai trebuie sa te autentifici.
Cod sursa(job #2763206)
Utilizator | Data | 12 iulie 2021 14:13:38 | |
---|---|---|---|
Problema | Aria | Scor | 0 |
Compilator | cpp-64 | Status | done |
Runda | Arhiva educationala | Marime | 1.49 kb |
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#define FOR(i , n) for(int i = 0 ; i < (n) ; i++)
#define apare printf("apare");
#define endl "\n"
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int , int> pii;
////==================================================
const int inf = INT_MAX;
struct point{
///structura de punct
int x, y;
bool operator < (const point& o){
return x * o.y - y * o.x < 0;
}
};
int dot(point p, point q){
///produsul scalar
return p.x * q.x + p.y * q.y;
}
int cross(point p, point q){
///produsul vectorial
return p.x * q.y - p.y * q.x;
}
int cross(point p1, point p2, point p3) {
///produs vectorial 3 puncte
return (p2.x - p1.x)*(p3.y - p1.y) - (p3.x - p1.x)*(p2.y - p1.y);
}
double area(vector<point>& v){
///aria delimitata d o multime de puncte
double res = 0;
int n = v.size();
for(int i=0; i<n; i++)
res += cross(v[i], v[(i+1)%n]);
return res;
}
//vector<point> v;
//populare cu puncte dintr-un singur cadran
//sort(v.begin(), v.end());
signed main() {
ios_base::sync_with_stdio(false);
cin.tie(nullptr);
cout.tie(nullptr);
freopen("aria.in" , "r" , stdin);
freopen("aria.out" , "w" , stdout);
int n;
cin >> n;
vector<point> sequence;
int a , b;
FOR(i , n){
cin >> a >> b;
sequence.push_back({a , b});
}
printf("%.5llf" , 0.5 * area(sequence));
return 0x0;
}