Участник:Иван Тунёв/group

Материал из DISCOPAL
Перейти к: навигация, поиск

https://www.codechef.com/problems/GRP2

def choose(set_number, elements_number):
    if 0 <= elements_number <= set_number:
        par_1 = 1
        par_2 = 1
        for par_3 in range(1, min(elements_number, set_number - elements_number) + 1):
            par_1 *= set_number
            par_2 *= par_3
            set_number -= 1
        return par_1 // par_2
    return 0
 
MEN, WOMEN, GROUP_SIZE = map(int, input().split())
 
NO_WOMEN = choose(MEN, GROUP_SIZE)
 
NO_MEN = 0
for j in range(GROUP_SIZE - 3, GROUP_SIZE + 1):
    NO_MEN += choose(WOMEN, j)*choose(MEN, GROUP_SIZE - j)
 
ALL_GROUPS = choose(MEN + WOMEN, GROUP_SIZE)
RIGHT_GROUPS = ALL_GROUPS - (NO_WOMEN + NO_MEN)
 
print(RIGHT_GROUPS)