您的位置:首页 > 其它

Codeforces 630F - Selection of Personnel

2016-03-08 19:26 351 查看
http://www.codeforces.com/problemset/problem/630/F

F. Selection of Personnel

time limit per test
0.5 seconds

memory limit per test
64 megabytes

input
standard input

output
standard output

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.

Examples

input
7


output
29


//排列组合 计算Cn5+Cn6+Cn7的值

#include <cstdio>
//33319741730082870
#define LL __int64
LL zuHe(LL n,int m)
{
if(n<m) return 0;
if(n==m) return 1;
LL ans=1;
int j=2;
for(int i=n-m+1;i<=n;++i)
{
ans*=i;
while(j<=m&&ans%j==0)
{
ans/=j;
++j;
}
}
while(j<=m)
{
ans/=j;
++j;
}
return ans;
}
int main()
{
LL n;
while(~scanf("%I64d",&n))
{
LL ans=0;
for(int i=5;i<=7;++i)
{
ans+=zuHe(n,i);
}
printf("%I64d\n",ans);

}
return 0;
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: