Skip to content

Commit f61cb15

Browse files
Merge pull request #552 from egg-silver/main
[이지은] 70차 라이브코테 제출
2 parents c088fa9 + d1fe4a8 commit f61cb15

File tree

2 files changed

+65
-0
lines changed

2 files changed

+65
-0
lines changed

live6/test70/문제1/이지은.js

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
const input = require('fs')
2+
.readFileSync(process.platform === 'linux' ? '/dev/stdin' : './input.txt')
3+
.toString()
4+
.trim()
5+
.split('\n')
6+
.map(Number);
7+
8+
function combination(n, r) {
9+
if (r > n || r < 0) return 0;
10+
r = Math.min(r, n - r);
11+
let result = 1;
12+
for (let i = 0; i < r; i++) {
13+
result *= n - i;
14+
result /= i + 1;
15+
}
16+
return result;
17+
}
18+
19+
function solution(input) {
20+
const [n, m] = input;
21+
22+
if (n > m) return 0;
23+
24+
const remainingFruits = m - n;
25+
const result = combination(remainingFruits + n - 1, n - 1);
26+
return result;
27+
}
28+
29+
console.log(solution(input));

live6/test70/문제2/이지은.js

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(process.platform === 'linux' ? '/dev/stdin' : './input.txt')
3+
.toString()
4+
.trim()
5+
.split('\n');
6+
7+
function solution(input) {
8+
let index = 0;
9+
const T = Number(input[index++]);
10+
const results = [];
11+
12+
for (let t = 0; t < T; t++) {
13+
const n = Number(input[index++]);
14+
const clothesMap = {};
15+
16+
for (let i = 0; i < n; i++) {
17+
const [item, type] = input[index++].split(' ');
18+
if (clothesMap[type]) {
19+
clothesMap[type]++;
20+
} else {
21+
clothesMap[type] = 1;
22+
}
23+
}
24+
25+
let result = 1;
26+
for (const type in clothesMap) {
27+
result *= clothesMap[type] + 1;
28+
}
29+
30+
results.push(result - 1);
31+
}
32+
33+
return results.join('\n');
34+
}
35+
36+
console.log(solution(input));

0 commit comments

Comments
 (0)