Cod sursa(job #3370208)

Utilizator builder23Nicolae Spaidar builder23 Data 24 octombrie 2026 14:51:27
Problema Aria Scor 0
Compilator c-64 Status done
Runda Arhiva educationala Marime 0.66 kb
#include <stdio.h>

int main()
{
    int N, x1, y1, x2, y2, x_start, y_start; 
    long long ans = 0;
    float ans_float = 0;

    FILE *f = fopen("aria.in", "r");
    FILE *g = fopen("aria.out", "w");
    if (f == NULL)
    {
        perror("aria.in");
        return 1;
    }

    fscanf(f, "%d", &N);
    fscanf(f, "%d %d", &x1, &y1);
    x_start = x1; y_start = y1;

    while (fscanf(f, "%d %d", &x2, &y2) == 2)
    {
        ans += 1LL * x1 * y2 - 1LL * x2 * y1;

        x1 = x2; y1 = y2;
    }
    
    ans += 1LL * x1 * y_start - 1LL * x_start * y1;

    ans_float = ans * 0.5;
    fprintf(g, "%.5f", ans_float);


    fclose(f);
    fclose(g);

    return 0;
}