Cod sursa(job #2333957)

Utilizator k.bruenDan Cojocaru k.bruen Data 2 februarie 2019 10:00:06
Problema Aria Scor 100
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 0.57 kb
#include <fstream>
#include <iomanip>

int main(int argc, const char * argv[]) {
    std::ifstream fin("aria.in");
    
    int n;
    fin >> n;
    
    long double result = 0;
    
    long double x1, y1;
    fin >> x1 >> y1;
    long double x = x1, y = y1;
    
    for (int i = 0; i < n; i++) {
        long double x2, y2;
        fin >> x2 >> y2;
        
        result += (x1*y2 - x2*y1) / 2;
        
        x1 = x2;
        y1 = y2;
    }
    
    result += (x1*y - x*y1) / 2;
    
    std::ofstream fout("aria.out");
    fout << std::setprecision(5) << std::fixed << result;
}