Choose Without Order
Combinations answer the question: how many ways can you choose some items when the order does not matter? Given n and k, return C(n, k), the number of ways to choose k items from n. For example, choosing 2 people from 5 can be done in 10 ways.
Примеры
Ввод
5, 2Вывод
10Ввод
10, 5Вывод
252Ввод
50, 10Вывод
10272278170Нужно реализовать
def combination(n: int, k: int) -> int:
Теги
math
Prisijunkite, kad matytumėte pateikimų istoriją
PrisijungtiPrisijunkite, kad naudotumėte DI mentorių
PrisijungtiVisible tests
1
Input
5, 2Expected
102
Input
10, 5Expected
2523
Input
50, 10Expected
102722781704
Input
40, 10Expected
8476605285
Input
10, 10Expected
16
Input
999999, 5Expected
8.333208334041665e+27Focus radio
Paused · SomaFM · Fluid