Cod sursa(job #3363255)

Utilizator horia.boeriuBoeriu Horia Andrei horia.boeriu Data 14 august 2026 17:18:02
Problema Aria Scor 0
Compilator cpp-64 Status done
Runda Arhiva educationala Marime 1.13 kb
#include <bits/stdc++.h>
using namespace std;
const int MAX = 10000;
int dp[MAX + 1];
int readInt(FILE *fin) {
    int x, semn;
    char ch;
    ch = fgetc(fin);
    while (isspace(ch)) {
        ch = fgetc(fin);
    }
    semn = 1;
    if (ch == '-') {
        semn = -1;
        ch = fgetc(fin);
    }
    x = 0;
    while (isdigit(ch)) {
        x = x * 10 + ch - '0';
        ch = fgetc(fin);
    }
    return x * semn;

}
int minim(int a, int b) {
    return a < b ? a : b;
}
int main()
{
    FILE *fin, *fout;
    int n, i, px, py, ulx, uly, x, y;
    long long a;
    double a2;
    fin = fopen("aria.in", "r");
    fscanf(fin, "%d%d%d", &n, &px, &py);
    a = 0;
    ulx = px;
    uly = py;
    for (i = 1; i < n; i++) {
        x = readInt(fin);
        y = readInt(fin);
        a += (long long)ulx * y - (long long)uly * x;
        ulx = x;
        uly = y;
    }
    fclose(fin);
    if (n > 1) {
        a += (long long)ulx * py - (long long)uly * px;
    }
    a2 = a / (double)2;
    fout = fopen("aria.out", "w");
    fprintf(fout, "%.5lf\n", a2);
    fclose(fout);
    return 0;
}