Selection of Personnel (Codeforces 630F)
Tags: Math, combinatorics

One company of IT City decided to create a group of innovative developments consisting from 5 to 7 people and hire new employees for it. After placing an advertisment the company received n resumes. Now the HR department has to evaluate each possible group composition and select one of them. Your task is to count the number of variants of group composition to evaluate.

Input: The only line of the input contains one integer n (7 ≤ n ≤ 777) — the number of potential employees that sent resumes.

Output: Output one integer — the number of different variants of group composition.


Sample Inputs:
7

Sample Outputs:
29

Solution (Python):
import math

def c(n, k):
    if k < 0 or k > n:
        return 0
    return math.factorial(n) // (math.factorial(k) * math.factorial(n - k))
n = int(input())
print(c(n, 7) + c(n, 6) + c(n, 5))

Solution (Python):
""""""
n = int(input())

def f_c_a(x, l):
    res = 1
    for i in range(x, x - l, -1):
        res *= i
    fac = 1
    for i in range(1, l + 1):
        fac *= i
    return res // fac
print(f_c_a(n, 5) + f_c_a(n, 6) + f_c_a(n, 7))

Solution (Python):
import math
n = int(input())
a = 0
for i in range(5, 8):
    a += math.comb(n, i)
print(a)