Skip to content

Commit 55246b3

Browse files
committed
104차 1번 문제풀이
1 parent 64ec6e9 commit 55246b3

1 file changed

Lines changed: 36 additions & 0 deletions

File tree

Lines changed: 36 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
const input = require("fs")
2+
.readFileSync(
3+
process.platform === "linux"
4+
? "/dev/stdin"
5+
: require("path").join(__dirname, "input.txt"),
6+
"utf8"
7+
)
8+
.toString()
9+
.trim()
10+
.split("\n")
11+
.map(Number);
12+
13+
function solution(input) {
14+
const T = input[0];
15+
const N = input.slice(1);
16+
const dp = [];
17+
const result = [];
18+
dp[0] = 0;
19+
dp[1] = 1;
20+
dp[2] = 1;
21+
dp[3] = 1;
22+
dp[4] = 2;
23+
dp[5] = 2;
24+
25+
for (let i = 6; i <= Math.max(...N); i++) {
26+
dp[i] = dp[i - 1] + dp[i - 5];
27+
}
28+
29+
for (let i = 0; i < T; i++) {
30+
result[i] = dp[N[i]];
31+
}
32+
33+
return result.join("\n");
34+
}
35+
36+
console.log(solution(input));

0 commit comments

Comments
 (0)