20251103 baekjoon
This commit is contained in:
parent
dab2d539de
commit
34cef97753
18
code_study/Baekjoon/ts/2166.ts
Normal file
18
code_study/Baekjoon/ts/2166.ts
Normal file
@ -0,0 +1,18 @@
|
|||||||
|
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));
|
||||||
Loading…
x
Reference in New Issue
Block a user