codeforces 630F Selection of Personnel(组合数)
0.5 seconds
64 megabytes
standard input
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.
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 题意:给一个数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\n",sum);
}
return 0;
}
codeforces 630F Selection of Personnel(组合数)的更多相关文章
- Codeforces 300C Beautiful Numbers 【组合数】+【逆元】
<题目链接> 题目大意: 给出a和b,如果一个数每一位都是a或b,那么我们称这个数为good,在good的基础上,如果这个数的每一位之和也是good,那么这个数是excellent.求长度 ...
- codeforces 341C Iahub and Permutations(组合数dp)
C. Iahub and Permutations time limit per test 1 second memory limit per test 256 megabytes input sta ...
- CodeForces 837F - Prefix Sums | Educational Codeforces Round 26
按tutorial打的我血崩,死活挂第四组- - 思路来自FXXL /* CodeForces 837F - Prefix Sums [ 二分,组合数 ] | Educational Codeforc ...
- cf-公式专场
A. Again Twenty Five! time limit per test 0.5 seconds memory limit per test 64 megabytes input stand ...
- Codeforces 100548F - Color (组合数+容斥)
题目链接:http://codeforces.com/gym/100548/attachments 有n个物品 m种颜色,要求你只用k种颜色,且相邻物品的颜色不能相同,问你有多少种方案. 从m种颜色选 ...
- Codeforces GYM 100114 D. Selection 线段树维护DP
D. Selection Time Limit: 1 Sec Memory Limit: 256 MB 题目连接 http://codeforces.com/gym/100114 Descriptio ...
- Educational Codeforces Round 26 F. Prefix Sums 二分,组合数
题目链接:http://codeforces.com/contest/837/problem/F 题意:如题QAQ 解法:参考题解博客:http://www.cnblogs.com/FxxL/p/72 ...
- Codeforces 893E Counting Arrays:dp + 线性筛 + 分解质因数 + 组合数结论
题目链接:http://codeforces.com/problemset/problem/893/E 题意: 共q组数据(q <= 10^5),每组数据给定x,y(x,y <= 10^6 ...
- Codeforces 869C The Intriguing Obsession:组合数 or dp
题目链接:http://codeforces.com/problemset/problem/869/C 题意: 红色.蓝色.紫色的小岛分别有a,b,c个. 你可以在两个不同的岛之间架桥,桥的长度为1. ...
随机推荐
- awk输出单引号,双引号
双引号: awk '{print "\""}' #放大:awk '{print " \" "}' 使用“”双引号把一个双引 ...
- Linux 下查看文件字符编码和转换编码
Linux 下查看文件字符编码和转换编码 如果你需要在Linux中操作windows下的文件,那么你可能会经常遇到文件编码转换的问题.Windows中默认的文件格式是GBK(gb2312),而Linu ...
- POJ2135 最小费用最大流模板题
练练最小费用最大流 此外此题也是一经典图论题 题意:找出两条从s到t的不同的路径,距离最短. 要注意:这里是无向边,要变成两条有向边 #include <cstdio> #include ...
- bzoj2466: [中山市选2009]树
同上一题.(应该可以树形dp,然而我不会... #include<cstdio> #include<cstring> #include<iostream> #inc ...
- codeforces 340A The Wall(简单数学题)
题意:输入a,b,x,y,a,b分别是两人的步数(每a块砖,刷一次),则有一些砖被两人同时刷到了,问[x,y]区间内有多少块砖同时被两人刷到. 分析:就是求[x,y]中有多少个能把a,b的最小公倍数l ...
- MYSQL查询数据库表索引的硬盘空间占用
查询数据库的占用 SELECT CONCAT(ROUND(SUM(index_length)/(1024*1024), 2), ' MB') AS 'Total Index Size' , CONCA ...
- python - os.path,路径相关操作
python处理系统路径的相关操作: # -*- coding: utf-8 -*- import os # 属性 print '__file__: %s' % __file__ # 绝对路径(包含文 ...
- 【C#学习笔记】Dictionary容器使用
using System; using System.Collections.Generic; namespace ConsoleApplication { class Program { stati ...
- ORACLE 全局索引和本地索引
Oracle数据库中,有两种类型的分区索引,全局索引和本地索引,其中本地索引又可以分为本地前缀索引和本地非前缀索引.下面就分别看看每种类型的索引各自的特点. 全局索引以整个表的数据为对象建立索引,索引 ...
- 【JSP】JSP向MySQL写入|读出中文数据——乱码问题
注意第14行