codeforces 630~~【组合数 C(n,m)】
来源:互联网 发布:mac怎么显示桌面 编辑:程序博客网 时间:2024/05/16 15:19
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
7
29
组合数 : 求 C(n,5)+C(n,6)+C(n,7)
#include <cstdio> #include <cstring> #include <cmath> #include <cstdlib> #include <algorithm> #include <queue> #include <stack> #define INF 0x3f3f3f3f #define eps 1e-8 #define Si(a) scanf("%d", &a) #define Sl(a) scanf("%lld", &a) #define Sf(a) scanf("%lf", &a) #define Ss(a) scanf("%s", a) #define Pi(a) printf("%d\n", (a)) #define Pf(a) printf("%.2lf\n", (a)) #define Pl(a) printf("%lld\n", (a)) #define Ps(a) printf("%s\n", (a)) #define Wi(a) while((a)--) #define cle(a, b) memset(a, (b), sizeof(a)) #define MOD 1000000007 #define LL long long #define PI acos(-1.0) using namespace std;__int64 comb(__int64 n, int m){__int64 a, b;a = b = 1;while(m--){a *= (n-m);a /= b;++b;}return a;}int main(){__int64 n;while(scanf("%I64d", &n)==1){__int64 ans = 0;for(int i = 5; i <= 7; ++i){ans += comb(n, i);}printf("%I64d\n", ans);}return 0;}
Description
Because of budget cuts one IT company established new non-financial reward system instead of bonuses.
Two kinds of actions are rewarded: fixing critical bugs and suggesting new interesting features. A man who fixed a critical bug gets "I fixed a critical bug" pennant on his table. A man who suggested a new interesting feature gets "I suggested a new feature" pennant on his table.
Because of the limited budget of the new reward system only 5 "I fixed a critical bug" pennants and 3 "I suggested a new feature" pennants were bought.
In order to use these pennants for a long time they were made challenge ones. When a man fixes a new critical bug one of the earlier awarded "I fixed a critical bug" pennants is passed on to his table. When a man suggests a new interesting feature one of the earlier awarded "I suggested a new feature" pennants is passed on to his table.
One man can have several pennants of one type and of course he can have pennants of both types on his table. There are n tables in the IT company. Find the number of ways to place the pennants on these tables given that each pennant is situated on one of the tables and each table is big enough to contain any number of pennants.
Input
The only line of the input contains one integer n (1 ≤ n ≤ 500) — the number of tables in the IT company.
Output
Output one integer — the amount of ways to place the pennants on n tables.
Sample Input
2
24
题解
5面A锦旗发放方案为 11111,1112,122,113,14,23,5
方案数为 sum1=C(n,5)+4*C(n,4)+2*3*C(n,3)+2*2*C(n,2)+C(n,1)
3面B锦旗发放方案为 111,12,3
方案数为 sum2=C(n,3)+2*C(n,2)+C(n,1)
总方案数为ans=sum1*sum2
#include <cstdio> #include <cstring> #include <cmath> #include <cstdlib> #include <algorithm> #include <queue> #include <stack> #define INF 0x3f3f3f3f #define eps 1e-8 #define Si(a) scanf("%d", &a) #define Si64(a) scanf("%I64d", &a) #define Sl(a) scanf("%lld", &a) #define Sf(a) scanf("%lf", &a) #define Ss(a) scanf("%s", a) #define Pi(a) printf("%d\n", (a)) #define Pi64(a) printf("%I64d\n", (a)) #define Pf(a) printf("%.2lf\n", (a)) #define Pl(a) printf("%lld\n", (a)) #define Ps(a) printf("%s\n", (a)) #define Wi(a) while((a)--) #define cle(a, b) memset(a, (b), sizeof(a)) #define MOD 1000000007 #define LL long long #define PI acos(-1.0) #define prt(x, y) printf("%.12lf %.12lf\n", x*fy+y*fx+px, -x*fx+y*fy+py);using namespace std;long long comb(int n, int m){LL a, b;a = 1; b = 1;while(m--){a *= (n-m);a /= b;b++;}return a;}int main(){int n;while(Si(n)==1){LL sum1 = comb(n,5)+4*comb(n,4)+2*3*comb(n,3)+2*2*comb(n,2)+comb(n,1);LL sum2 = comb(n,3)+2*comb(n,2)+comb(n,1);Pl(sum1*sum2);}return 0;}
Description
The city park of IT City contains n east to west paths and n north to south paths. Each east to west path crosses each north to south path, so there are n2 intersections.
The city funded purchase of five benches. To make it seems that there are many benches it was decided to place them on as many paths as possible. Obviously this requirement is satisfied by the following scheme: each bench is placed on a cross of paths and each path contains not more than one bench.
Help the park administration count the number of ways to place the benches.
Input
The only line of the input contains one integer n (5 ≤ n ≤ 100) — the number of east to west paths and north to south paths.
Output
Output one integer — the number of ways to place the benches.
Sample Input
5
120
n*n个路口放 5 个凳子,并且每个路口只能放一个。求共有几种方式
#include <cstdio> #include <cstring> #include <cmath> #include <cstdlib> #include <algorithm> #include <queue> #include <stack> #define INF 0x3f3f3f3f #define eps 1e-8 #define Si(a) scanf("%d", &a) #define Si64(a) scanf("%I64d", &a) #define Sl(a) scanf("%lld", &a) #define Sf(a) scanf("%lf", &a) #define Ss(a) scanf("%s", a) #define Pi(a) printf("%d\n", (a)) #define Pi64(a) printf("%I64d\n", (a)) #define Pf(a) printf("%.2lf\n", (a)) #define Pl(a) printf("%lld\n", (a)) #define Ps(a) printf("%s\n", (a)) #define Wi(a) while((a)--) #define cle(a, b) memset(a, (b), sizeof(a)) #define MOD 1000000007 #define LL long long #define PI acos(-1.0) #define prt(x, y) printf("%.12lf %.12lf\n", x*fy+y*fx+px, -x*fx+y*fy+py);using namespace std;long long comb(int n, int m){LL a, b;a = 1; b = 1;while(m--){a *= (n-m);a /= b;b++;}return a;}int main(){int n;while(Si(n)==1){Pl(120*comb(n,5)*comb(n,5));}return 0;}
- codeforces 630~~【组合数 C(n,m)】
- 组合数C(n,m)
- 组合数算法 C(n,m)(n>=m)
- 计算组合数C(m,n)
- 变态组合数C(n,m)求解
- 求组合数c(n,m)
- 计算组合数C(n,m)
- 组合数C(n,m)的计算
- 求组合数(c(m,n))
- 求组合数C(n , m)
- 大组合数(C(n,m))
- 组合C(m,n)
- C++/C组合数A(m,n)
- C语言求组合数C(n,m)
- 求大数n,m下组合数C(n+m,m)%Mod
- 证明组合数c(n,m)是整数
- 组合数计算C(n,m)加取模情况
- poj 2249 Binomial Showdown[C(n, m)组合数求解]
- #import #include与@class的区别
- Poll机制分析
- C++函数基础
- Unable to instantiate Action, loginAction, defined for 'login' in namespace
- poj 1639 Picnic Planning 最小k度生成树
- codeforces 630~~【组合数 C(n,m)】
- Jquery Ajax的success:funtion(data)的data非son类型
- 学习笔记-去掉字符串两头的空格
- hihocoder 1032 最长回文子串 (Manacher算法 详解+模板)
- 龟兔赛跑的预测
- 指针学习笔记
- 欢迎使用CSDN-markdown编辑器
- 转 在@interface中的大括号中声明和@property区别
- 隐式(Synchronized)锁和显式(java.util.Lock)锁