Notice
Recent Posts
Recent Comments
Link
일 | 월 | 화 | 수 | 목 | 금 | 토 |
---|---|---|---|---|---|---|
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 |
Tags
- JS
- yarn-berry
- 파이썬
- 커스텀알락
- youtube iframe
- 백준
- css
- iP
- Rest
- React
- 프로토타입
- 타입스크립트
- firebaseui
- 리액트
- leetcode189
- 구조분해할당
- 파이어베이스로그인
- nvm
- Spread
- Python
- 자바스크립트
- Next.js
- leetcode977
- nvmrc
- react-native
- 커스텀알림
- mac
- 기초
- react-firebaseui
- 다리놓기
Archives
- Today
- Total
JadeCode
백준 1010 javascript (node js) 본문
//20210114
//다리놓기
//mCn
const input = require("fs")
.readFileSync("/dev/stdin")
.toString()
.trim()
.split("\n");
// const input = `3
// 2 2
// 1 5
// 13 29
// `.split("\n");
const t = input[0].split(" ").map(Number);
const dp = Array.from({ length: 30 }, () =>
Array.from({ length: 30 }, () => 0)
);
for (let i = 1; i < 30; i++) {
for (let j = 1; j < 30; j++) {
if (i === 1) {
dp[i][j] = j;
} else if (i === j) {
dp[i][j] = 1;
} else if (j > i) {
dp[i][j] = dp[i - 1][j - 1] + dp[i][j - 1];
}
}
}
// console.log(dp);
for (let i = 1; i <= t; i++) {
const [n, m] = input[i].split(" ").map(Number);
console.log(dp[n][m]);
}
'개발 > 알고리즘' 카테고리의 다른 글
[백준] python 2739 구구단 (0) | 2022.02.25 |
---|---|
[Python] 개념정리 - for문 index, value 접근 (0) | 2022.02.17 |
[백준] python 1018 체스판 다시 칠하기 (0) | 2022.01.24 |
[백준] python 1010 다리 놓기 (0) | 2022.01.21 |
자바스크립트로 백준 풀기 (0) | 2021.11.22 |
Comments