20250628 baekjoon
This commit is contained in:
parent
06fc04dace
commit
f453e943e9
15
code_study/Baekjoon/c/11050.c
Normal file
15
code_study/Baekjoon/c/11050.c
Normal file
@ -0,0 +1,15 @@
|
|||||||
|
#include <stdio.h>
|
||||||
|
|
||||||
|
int main() {
|
||||||
|
int n, k, result=1, factR=1;
|
||||||
|
scanf("%d %d", &n, &k);
|
||||||
|
|
||||||
|
for(int i=1; i<=k; i++) {
|
||||||
|
result *= n-i+1;
|
||||||
|
factR *= i;
|
||||||
|
}
|
||||||
|
|
||||||
|
printf("%d\n",result/factR);
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
2
code_study/Baekjoon/js/11050.js
Normal file
2
code_study/Baekjoon/js/11050.js
Normal file
@ -0,0 +1,2 @@
|
|||||||
|
const [n, k] = require("fs").readFileSync(0, "utf8").toString().trim().split(' ').map(Number);
|
||||||
|
console.log(Array.from({length:k}, (_,i) => n-i).reduce((acc,v) => acc*v,1) / Array.from({length:k}, (_,i) => i+1).reduce((acc,v) => acc*v,1));
|
||||||
6
code_study/Baekjoon/python/11050.py
Normal file
6
code_study/Baekjoon/python/11050.py
Normal file
@ -0,0 +1,6 @@
|
|||||||
|
n, k = map(int, input().split())
|
||||||
|
num=denom=1
|
||||||
|
for a,b in zip(range(n-k+1,n+1), range(1,k+1)):
|
||||||
|
num *= a
|
||||||
|
denom *= b
|
||||||
|
print(num//denom)
|
||||||
Loading…
x
Reference in New Issue
Block a user