Description
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 Input
Input
7
Output
29
题目:求n对5,6,7的组合数之和;即;
但由于数据太大,要进行特殊处理,以免超出最大的计算位数,看下面代码:
AC代码:
#include<stdio.h> #include<iostream> #include<string.h> #include<algorithm> using namespace std; int main() { __int64 n; while(scanf("%I64d",&n)!=EOF) { __int64 t1,t2,t3,temp; temp= n*(n-1)/2*(n-2)*(n-3)/2*(n-4); //任意两个相邻的数字,必然有一个偶数; t1=temp/30; t2=temp*(n-5)/180; t3=temp*(n-5)/5*(n-6)/252;//任意两个相邻的数字,必然有一个偶数;任意6个相连的数字必能整除以5; printf("%I64d\n",t1+t2+t3); } return 0; }