Skip to content

Commit 5340c75

Browse files
author
Eric
committed
102차 1번 문제풀이
1 parent aa918fb commit 5340c75

1 file changed

Lines changed: 20 additions & 0 deletions

File tree

Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
const input = +require('fs')
2+
.readFileSync(process.platform === 'linux' ? '/dev/stdin' : './input.txt')
3+
.toString()
4+
.trim();
5+
6+
function solution(input) {
7+
const n = input;
8+
const dp = Array(n + 1).fill(0);
9+
10+
dp[1] = 1;
11+
dp[2] = 3;
12+
13+
for (let i = 3; i <= n; i++) {
14+
dp[i] = (dp[i - 1] + 2 * dp[i - 2]) % 10007;
15+
}
16+
17+
return dp[n];
18+
}
19+
20+
console.log(solution(input));

0 commit comments

Comments
 (0)