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.
The only line of the input contains one integer n (7 ≤ n ≤ 777) — the number of potential employees that sent resumes.
Output one integer — the number of different variants of group composition.
7
29
#include<cstdio>
#include<cstring>
#include<iostream>
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
//重点在于计算C(n,i) 要防止超时
//题目大意:收到n个人的简历,要组成一个团队(人数为5或6或7)
//即 计算C(n,5)+C(n,6)+C(n,7);
long long C(long long n,long long i)
{
//printf("%lld %lld\n",n,i);
long long num=1;
long long k,j;
for(j=n,k=1;k<=i&&j>=n-i+1;k++,j--)
{
num=num*j;
num=num/k;
}
//printf("%lld\n",num);
return num;
}
int main()
{
long long n;
while(scanf("%lld",&n)!=EOF)
{
if(n==5)
{
printf("1\n");
}
else if(n==6)
{
printf("7\n");
}
else if(n==7)
{
printf("29\n");
}
else
{
long long i;
long long sum=0;
for(i=7;i>=5;i--)
{
sum=sum+C(n,i);
}
printf("%lld\n",sum);
}
}
return 0;
}