티스토리 뷰
https://www.acmicpc.net/problem/20157
const [N, ...targets] = require('fs')
.readFileSync('./dev/stdin')
.toString()
.trim()
.split('\n')
.map((v) => v.split(' ').map(Number));
const getGCD = (num1, num2) => {
while (num2 > 0) {
let r = num1 % num2;
num1 = num2;
num2 = r;
}
return num1;
};
const leans = new Map();
targets.forEach((v) => {
[x, y] = v;
let lean;
if (x == 0 && y > 0) {
lean = '+0';
} else if (x == 0 && y < 0) {
lean = '-0';
} else if (x < 0 && y == 0) {
lean = '-Infinity';
} else if (x > 0 && y == 0) {
lean = 'Infinity';
} else {
const gcd = getGCD(Math.abs(x), Math.abs(y));
lean = `${x / gcd}/${y / gcd}`;
}
if (leans.has(lean)) {
const cnt = leans.get(lean);
leans.set(lean, cnt + 1);
} else {
leans.set(lean, 1);
}
});
const max = Math.max(...leans.values());
console.log(max);
728x90
'자료구조 알고리즘 > 백준' 카테고리의 다른 글
Node.js) 백준 29790번: 임스의 메이플컵 (0) | 2023.09.15 |
---|---|
Node.js) 백준 22234번: 가희와 은행 (0) | 2023.09.15 |
Node.js) 백준 17839번: Baba is Rabbit (0) | 2023.09.13 |
Node.js) 백준 20311번: 화학 실험 (0) | 2023.09.13 |
Node.js) 백준 1501번: 영어 읽기 (0) | 2023.09.13 |
공지사항
최근에 올라온 글
최근에 달린 댓글
- Total
- Today
- Yesterday
링크
TAG
- BFS
- node.js
- 개발자면접
- 다이나밍프로그래밍
- 은둔청년체험
- 동적프로그래밍
- MOD
- 로드나인
- MySQL
- 투포인터 연습
- 면접비
- 최소공통조상
- 서버점검
- 투포인터
- 면접질문
- DB 생성
- 그래프
- 다이나믹프로그래밍
- create db
- 롱베케이션
- create databases;
- 서버개발
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
1 | ||||||
2 | 3 | 4 | 5 | 6 | 7 | 8 |
9 | 10 | 11 | 12 | 13 | 14 | 15 |
16 | 17 | 18 | 19 | 20 | 21 | 22 |
23 | 24 | 25 | 26 | 27 | 28 |
글 보관함