zoukankan      html  css  js  c++  java
  • codeforces 630F Selection of Personnel(组合数)

    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

    题意:给一个数n(7<=n<=777)要求从这n个人中抽5到7个问总共多少种可能
    题解:组合数c(n,5)+c(n,6)+c(n,7)注意防止溢出
    #include<stdio.h>
    #include<string.h>
    #include<string>
    #include<math.h>
    #include<algorithm>
    #define LL long long
    #define PI atan(1.0)*4
    #define DD double
    #define MAX 10010
    #define mod 100
    #define dian 1.000000011
    #define INF 0x3f3f3f
    using namespace std;
    LL solve(LL n,LL m)  
    {  
        int num=1;  
        LL ans=1;  
        while(m--)  
        {  
            ans*=(n-m);  
            ans/=num;  
            num++;  
        }  
        return ans;  
    }  
    int main()
    {
    	LL n,m,j,i,x,y;
    	LL sum,a,b,c,ans;
        while(scanf("%lld",&n)!=EOF)
    	{	
    	    sum=0;
    		for(i=5;i<=7;i++)
    		{
    			sum+=solve(n,i);
    		}
    		printf("%lld
    ",sum);
    	} 
    	return 0;
    } 
    

      

  • 相关阅读:
    Atlassian In Action-Jira之核心配置(二)
    mybatis的插入与批量插入的返回ID的原理
    Atlassian In Action-Jira之指导思想(一)
    Atlassian In Action
    如何进行软件技术管理?
    [simple-orm-mybaits]基于Mybatis的ORM封装介绍
    Java利用Mybatis进行数据权限控制
    给大家推荐一个Java学习和面试的GitHub项目
    立志
    一勤天下无难事
  • 原文地址:https://www.cnblogs.com/tonghao/p/5251559.html
Copyright © 2011-2022 走看看