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 | 29 | 30 | 31 |
Tags
- js ๋ฌธ์์ด ์์ถ
- ๋ฐฑ์ค 2108 nodejs
- ์๋ฐ์คํฌ๋ฆฝํธ ๋ฌธ์์ด ์์ถ
- ๋ฆฌ์กํธ์ฟผ๋ฆฌ suspense
- suspense ๋ณ๋ชฉํ์
- ๊ตฌ๋ฆํค
- ํ๋ก๊ทธ๋๋จธ์ค ๋ฌธ์์ด ์์ถ
- ์ต์ ๋์ฒด์ด๋
- emtion app router
- js ์ค์ฝํ
- ์ค์ฝํ
- js ๊ฑฐ๋ฆฌ๋๊ธฐ ํ์ธํ๊ธฐ
- ๊ตฌ๋ฆํค ์ฑ๋ฆฐ์ง
- ์นด์นด์ค ์ฝํ
- suspense ๋์์๋ฆฌ
- emotion RSC
- ๋ฐฑ์ค 1339๋ฒ ์๋ฐ์คํฌ๋ฆฝํธ
- app router emotion
- suspense react-query
- ํ๋ก๊ทธ๋๋จธ์ค ๊ฑฐ๋ฆฌ๋๊ธฐ ํ์ธํ๊ธฐ
- js
- ๋ฐฑ์ค 1339๋ฒ nodejs
- ๋ฐฑ์ค 2108 ์๋ฐ์คํฌ๋ฆฝํธ
- ๋ฐฑ์ค 1339๋ฒ js
- ๊ตฌ๋ฆํค ์ฑ๋ฆฐ์ง ํ๊ณ
- next13 emotion
- suspense ๋น๋๊ธฐ
- ์ฌ์ฉ์ฑ ๊ฐ์
- TypeError: createContext only works in Client Components. Add the "use client" directive at the top of the file to use it. Read more:
- ์๋ฐ์คํฌ๋ฆฝํธ ์ค์ฝํ
Archives
- Today
- Total
Lennon FE
[๋ฐฑ์ค 11057๋ฒ] ์ค๋ฅด๋ง ์ - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs) ๋ณธ๋ฌธ
๐ฅ Algorithm/Baekjoon
[๋ฐฑ์ค 11057๋ฒ] ์ค๋ฅด๋ง ์ - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs)
Lennon 2022. 3. 18. 20:12728x90
๋ฐ์ํ
https://www.acmicpc.net/problem/11057
const { off } = require('process');
const readline = require('readline');
const rl = readline.createInterface({
input: process.stdin,
output: process.stdout,
});
let input;
rl.on('line', function (line) {
input = +line;
rl.close();
}).on('close', function () {
const dp = Array.from(Array(input + 1), () => new Array());
dp[1] = [1, 1, 1, 1, 1, 1, 1, 1, 1, 1];
dp[2] = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10];
for (let i = 3; i <= input; i++) {
for (let j = 0; j < dp[i - 1].length; j++) {
const value = [...dp[i - 1]];
dp[i][j] = value.slice(0, j + 1).reduce((acc, cur) => acc + cur) % 10007;
}
}
console.log(dp[input].reduce((acc, cur) => acc + cur) % 10007);
});
์ ํ์ ์ธ DP๋ฌธ์ ์ด๋ค. ์ฌ์ด DP๋ฌธ์ ์์ ๊ฐ์ฅ ๋ง์ด ์ฌ์ฉํ๋ ์ฉ๋ฒ์ธ ๊ฒ ๊ฐ๋ค.
N | ||||||||||
1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 | 1 |
2 | 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 |
3 | 1 | 3 | 6 | 10 | 15 | 21 | 28 | 36 | 45 | 55 |
4 | 1 | 4 | 10 | 20 | 35 | 56 | 84 | 120 | 165 | 220 |
N์ ๊ทธ๋ฅ ์ ๋ถ๋ถ์ index๋งํผ ๋ํ ๊ฐ์ ๋ฃ์ด์ฃผ๋ฉด ๋๋ค.
ex) N์ด 4์ธ ๊ฒฝ์ฐ์์ 3๋ฒ์งธ ์ธ๋ฑ์ค์ธ 20์ N์ด i-1์ธ 3์์ 1+3+6+10 ํ ๊ฒฐ๊ณผ์ ๊ฐ์!
์ฝ๋ฉํ ์คํธ์์ DP๋ฌธ์ ๋ฅผ ๋ดค์ ๋ ๋์ ๋๋ ๋๋์ด ๋ ๋ค๋ฉด ์์ฒ๋ผ ๋์ํ๋ ์ง ํ์ธํด๋ณด์
728x90
๋ฐ์ํ
'๐ฅ Algorithm > Baekjoon' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[๋ฐฑ์ค 14490๋ฒ] ๋ฐฑ๋์ด - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs) (0) | 2022.04.05 |
---|---|
[๋ฐฑ์ค 10610๋ฒ] 30 - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs) (0) | 2022.04.05 |
[๋ฐฑ์ค 1309๋ฒ] ๋๋ฌผ์ - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs) (0) | 2022.03.18 |
[๋ฐฑ์ค 1260๋ฒ] DFS์ BFS - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs) (0) | 2022.03.18 |
[๋ฐฑ์ค 17144๋ฒ] ๋ฏธ์ธ๋จผ์ง ์๋ ! - ์๋ฐ์คํฌ๋ฆฝํธ(nodejs) (0) | 2022.03.16 |
Comments