Cod sursa(job #2448117)

Utilizator dakataIonescu Valentin-Alexandru dakata Data 15 august 2019 19:53:12
Problema Aria Scor 0
Compilator java Status done
Runda Arhiva educationala Marime 1.41 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.FileInputStream;
import java.io.FileNotFoundException;
import java.io.PrintStream;
import java.util.Scanner;

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

    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[] cuv;
        String[] cuv_2;
        int sum = 0;
        int N = Integer.parseInt(scanner.nextLine());
        for (int i = 0; i < N / 2; i++) {

            line_1 = scanner.nextLine();
            line_2 = scanner.nextLine();
            cuv = line_1.split(" ");
            cuv_2 = line_2.split(" ");
            sum += Integer.parseInt(cuv[0]) * Integer.parseInt(cuv_2[1]) - Integer.parseInt(cuv_2[0]) * Integer.parseInt(cuv[1]);
        }
        if (N % 2 == 1) {
            line_1 = line_2;
            line_2 = scanner.nextLine();
            cuv_2 = line_2.split(" ");
            cuv = line_1.split(" ");
            sum += Integer.parseInt(cuv[0]) * Integer.parseInt(cuv_2[1]) - Integer.parseInt(cuv_2[0]) * Integer.parseInt(cuv[1]);
        }
        writer.println(sum);
    }
}