18 lines
496 B
TypeScript
18 lines
496 B
TypeScript
export {};
|
|
|
|
const square = (N: number, point: number[][]): string => {
|
|
let temp = 0;
|
|
for(let i=0; i<N; i++) {
|
|
temp += point[i][0]*point[i+1][1] - point[i+1][0]*point[i][1];
|
|
}
|
|
return (0.5*Math.abs(temp)).toFixed(1);
|
|
}
|
|
|
|
const input = require("fs").readFileSync(0).toString().trim().split('\n');
|
|
const N = Number(input[0]);
|
|
|
|
let point: number[][] = [];
|
|
for(let i=1; i<=N; i++) point.push(input[i].split(" ").map(Number));
|
|
point.push(point[0]);
|
|
|
|
console.log(square(N, point)); |