We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
1 parent dfaa21d commit 66ef847Copy full SHA for 66ef847
live6/test70/문제1/이지은.js
@@ -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
27
28
29
+console.log(solution(input));
0 commit comments