Submission details
Task:Polygon area
Sender:Giaco
Submission time:2025-11-10 16:48:22 +0200
Language:Rust (2021)
Status:COMPILE ERROR

Compiler report

error[E0433]: failed to resolve: use of undeclared crate or module `num`
  --> input/code.rs:44:20
   |
44 |     println!("{}", num::abs(rtn));
   |                    ^^^ use of undeclared crate or module `num`

error: aborting due to previous error

For more information about this error, try `rustc --explain E0433`.

Code

use std::io::{self, Read};

macro_rules! input {
    ($it: expr) => {
        $it.next().unwrap().parse().unwrap()
    };
    ($it: expr, $T: ty) => {
        $it.next().unwrap().parse::<$T>().unwrap()
    };
}
/*
mod classes;
mod homework;

fn main() {
    // println!("{}", "-".repeat(20));
    classes::c20::task1();
    // homework::hw9::task1();
    // println!("{}", "-".repeat(20));
}
// */

fn cross_product(a: (i128, i128), b: (i128, i128)) -> i128 {
    a.0*b.1 - b.0*a.1
}

fn main() {
    let mut buf = String::new();
    io::stdin().read_to_string(&mut buf).unwrap();

    let mut it = buf.split_whitespace();

    let n: usize = input!(it);

    let v: Vec<(i128, i128)> = (0..n).into_iter().map(|_| (input!(it), input!(it))).collect();

    let mut rtn = 0;

    for i in 0..n-1 {
        rtn += cross_product(v[i], v[i+1]);
    }
    rtn += cross_product(v[n-1], v[0]);

    println!("{}", num::abs(rtn));
}