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. ...
随机推荐
- apns-http2-php,苹果push升级到http2
最近公司push推送升级,用苹果http2进行推送,http2的好处就不说了,这些网上都可以查到,但是真正在项目中用的,用php写的还是特别少,因此,写出来跟大家分享,废话不说了,直接上代码: pus ...
- c# webbrowser 随机点击链接 2
找到广告代码所在的div或table ,然后用WebBrowser执行js去点这个div(或table) 那个广告是js实现的,你浏览的时候是看不到图片和连接的,请问各位大虾应该怎么实现?给点思路.. ...
- bzoj1566
好题,这道题体现了换一个角度计数的思想 a1^2+a2^2+……ak^2=(变成第1种输出序列的操作序列数目)^2+(变成第2种输出序列的操作序列数目)^2…… 脑洞大一点,这就相当于两个操作序列变成 ...
- bzoj2251
以前看到这道题想到的是SA,做起来不是很美观 学了SAM之后,这题简直是随便搞 ..,'] of longint; s,sa,mx,w,fa:..] of longint; i,n,last,t:lo ...
- maven常用构建命令
mvn -v 查看maven版本 compile 编译项目 install 将项目加入到本地仓库中 clean 删除target test 测试 package 打包
- UVa 10253 (组合数 递推) Series-Parallel Networks
<训练之南>上的例题难度真心不小,勉强能看懂解析,其思路实在是意想不到. 题目虽然说得千奇百怪,但最终还是要转化成我们熟悉的东西. 经过书上的神分析,最终将所求变为: 共n个叶子,每个非叶 ...
- busybox filesystem ts_config: No such file or directory
/******************************************************************** * busybox filesystem ts_config ...
- HDU 3749 Financial Crisis 经济危机(点双连通分量)
题意: 给一个图n个点m条边(不一定连通),接下来又q个询问,询问两个点是为“不相连”,“仅有一条路径可达”,“有两条及以上的不同路径可达”三种情况中的哪一种.注:两条以上的路径指的是路径上的点连1个 ...
- table_open_cache
当 MySQL 访问一个表时,如果该表在缓存中已经被打开,则可以直接访问缓存:如果还没有被缓存,但是在MySQL表缓冲区中还有空间,那么这个表就被打开并放入表缓冲区:如果表缓存满了,则会按照一定的规则 ...
- Chrome的网络调试
F12 然后