Cod sursa(job #2448133)

Utilizator dakataIonescu Valentin-Alexandru dakata Data 15 august 2019 20:34:10
Problema Aria Scor 0
Compilator java Status done
Runda Arhiva educationala Marime 1.59 kb


/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */
import java.io.*;
import java.util.*;

/**
 *
 * @author dakata
 */
public class Main {

    /**
     * @param args the command line arguments
     */
    /*
    public static void main(String[] args) throws FileNotFoundException {
        // TODO code application logic here
        Scanner scanner = new Scanner(new FileInputStream("adunare.in"));
        PrintStream writer = new PrintStream("adunare.out");
                
        int a = Integer.parseInt(scanner.nextLine());
        int b = Integer.parseInt(scanner.nextLine());
        writer.println(a+b);
        
    }
     */
    public static void main(String[] args) throws FileNotFoundException {

        Scanner scanner = new Scanner(new FileInputStream("aria.in"));
        PrintStream writer = new PrintStream("aria.out");
        String line_1 = "";
        String line_2 = "";
        String first = "";

        int sum = 0;
        int N = Integer.parseInt(scanner.nextLine());
        String[] cuv = new String[N + 1];
        String[] cuv_2;

        for (int i = 0; i < N; i++) {

            cuv[i] = scanner.nextLine();
        }
        cuv[N] = cuv[0];
        for (int i = 0; i < N; i++) {
            cuv_2 = cuv[i].split(" ");
            String[] tmp = cuv[i + 1].split(" ");
            sum+= Integer.parseInt(cuv_2[0]) * Integer.parseInt(tmp[1]) - Integer.parseInt(cuv_2[1]) * Integer.parseInt(tmp[0]); 
        }
        writer.println(sum / 2);
    }

}