
排列组合
文章平均质量分 58
Joefery
生命不息,战斗不止。
展开
-
盒子放球问题
k个相同的盒子放进n个不同的盒子,求有多少种放法。输入:3 41 4输出:151首先介绍插板法:(字数比较多,直接从网上一篇文章上截图)也就是说,把k个相同的球放进n个不同的盒子,公式为C(k-1,n-1)。这道题的公式可以从插板法推导出来。对比题目发现插板法和这道题的区别在于并不是每个盒子都至少有一个球的。那么我们可以假设,每个盒子内已经有原创 2016-07-11 17:24:34 · 2190 阅读 · 0 评论 -
codeforces #630 I. Parking Lot
题目链接4种不同的汽车,有2n-2个停车位,要求恰有n辆相同的车排在一起,问有多少种停车方案 分类讨论:1)n辆车在停车场两端,方案数为2*4*3*4^(n-3),2)n辆车不在两端,方案为4*(n-3)3*3*4^(n-4),所以总的停车方案有 24*4^(n-3)+36(n-3)*4^(n-4) #include原创 2016-07-13 20:09:57 · 442 阅读 · 0 评论 -
codeforces 630H. Benches
题目链接一座城市有n条南北走向的街道和n条东西走向的街道,现要将5条不用的长凳放置在街道相交处,且同一条街道上的长凳数不超过一条,问有多少种放置方案 #include#include#include#include#includeusing namespace std;typedef long long LL;LL C(LL n,LL r){ LL i原创 2016-07-13 18:54:53 · 474 阅读 · 0 评论 -
codefoces #630 G. Challenge Pennants
题目链接#include#include#include#include#includeusing namespace std;typedef long long LL;LL C(LL n,LL r){ LL i,j,s=1; if(r>n)return 0; if(n-r<r)r=n-r; for(i=0,j=1;i<r;i++){原创 2016-07-13 15:28:55 · 466 阅读 · 0 评论 -
codeforces #630 F. Selection of Personnel
题目链接排列组合 计算 C(N,5)+C(N,6)+C(N,7)#include#include#include#include#includeusing namespace std;typedef long long LL;LL C(LL n,LL r){ LL i,j,s=1; if(n-r<r)r=n-r; for(i=0,j=1;i<r原创 2016-07-13 13:16:33 · 559 阅读 · 0 评论 -
A. Far Relative’s Birthday Cake【排列组合】
time limit per test 1 secondmemory limit per test 256 megabytesinput standard inputoutput standard outputDoor's family is going celebrate Famil Doors's birthday party原创 2016-03-11 19:02:42 · 709 阅读 · 0 评论 -
Gym 101138C Stickmen【枚举+排列组合】
Descriptionstandard input/outputStatementsLimak is a little bear who loves to play with graphs. Recently, he defined a new structure in a graph and called it a stickman.A stickman is a set原创 2016-10-28 11:52:06 · 788 阅读 · 0 评论