Skip to content

Commit 0c9531b

Browse files
author
Eric
committed
104차 1번 문제풀이
1 parent 64ec6e9 commit 0c9531b

1 file changed

Lines changed: 26 additions & 0 deletions

File tree

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
const input = require('fs')
2+
.readFileSync(process.platform === 'linux' ? '/dev/stdin' : './input.txt')
3+
.toString()
4+
.trim()
5+
.split('\n')
6+
.map((el) => el.split(' ').map(Number));
7+
8+
function solution(input) {
9+
const T = input[0][0];
10+
const nums = input.slice(1);
11+
const dp = Array(101).fill(0);
12+
13+
dp[1] = 1;
14+
dp[2] = 1;
15+
dp[3] = 1;
16+
dp[4] = 2;
17+
dp[5] = 2;
18+
19+
for (let i = 6; i <= 100; i++) {
20+
dp[i] = dp[i - 1] + dp[i - 5];
21+
}
22+
23+
return nums.map((n) => dp[n]).join('\n');
24+
}
25+
26+
console.log(solution(input));

0 commit comments

Comments
 (0)