Skip to content

Commit f5c335f

Browse files
Merge pull request #704 from eric-hjh/main
[황장현] 108차 라이브 코테 제출
2 parents ea90b7a + 354fec9 commit f5c335f

File tree

2 files changed

+37
-0
lines changed

2 files changed

+37
-0
lines changed
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
const input = require('fs')
2+
.readFileSync(process.platform === 'linux' ? '/dev/stdin' : './input.txt')
3+
.toString()
4+
.trim();
5+
6+
const parts = input.split('-');
7+
8+
let result = parts[0].split('+').reduce((acc, num) => acc + parseInt(num), 0);
9+
10+
for (let i = 1; i < parts.length; i++) {
11+
const sum = parts[i].split('+').reduce((acc, num) => acc + parseInt(num), 0);
12+
result -= sum;
13+
}
14+
15+
console.log(result);
Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
const input = require('fs')
2+
.readFileSync(process.platform === 'linux' ? '/dev/stdin' : './input.txt')
3+
.toString()
4+
.trim()
5+
.split(' ')
6+
.map(Number);
7+
8+
const [N, K] = input;
9+
10+
const dp = Array.from({ length: K + 1 }, () => Array(N + 1).fill(0));
11+
12+
for (let i = 0; i <= K; i++) {
13+
dp[i][0] = 1;
14+
}
15+
16+
for (let i = 1; i <= K; i++) {
17+
for (let j = 1; j <= N; j++) {
18+
dp[i][j] = (dp[i][j - 1] + dp[i - 1][j]) % 1000000000;
19+
}
20+
}
21+
22+
console.log(dp[K][N]);

0 commit comments

Comments
 (0)