组合数学
爱上键盘的小哥哥
这个作者很懒,什么都没留下…
展开
-
HDU2048 神、上帝以及老天爷(错排)
HDU 2006'10 ACM contest的颁奖晚会隆重开始了! 为了活跃气氛,组织者举行了一个别开生面、奖品丰厚的抽奖活动,这个活动的具体要求是这样的: 首先,所有参加晚会的人员都将一张写有自己名字的字条放入抽奖箱中; 然后,待所有字条加入完毕,每人从箱中取一个字条; 最后,如果取得的字条上写的就是自己的名字,那么“恭喜你,中奖了!” 大家可以想象一下当时的气氛之原创 2017-09-11 10:58:26 · 195 阅读 · 0 评论 -
HEX(组合数学+逆元+思维)
Problem DescriptionOn a plain of hexagonal grid, we define a step as one move from the current grid to the lower/lower-left/lower-right grid. For example, we can move from (1,1) to (2,1), (2,2) or (3,...原创 2018-05-03 17:01:49 · 189 阅读 · 0 评论 -
求组合数的多种方法
参考自点击打开链接求C(n,m)%mod的方法总结1.当n,m都很小的时候可以利用杨辉三角直接求。 C(n,m)=C(n-1,m)+C(n-1,m-1);2.利用乘法逆元。 乘法逆元:(a/b)%mod=a*(b^(mod-2)) mod为素数。 逆元可以利用扩展欧几里德或欧拉函数求得:1).扩展欧几里德:b*x+p*y=1 有解,x就是所求2).费马小定理:b^(p-1)=1(mod p)...原创 2018-04-08 15:18:08 · 425 阅读 · 1 评论 -
Wand FZU - 2282(组合数学+错排公式)
N wizards are attending a meeting. Everyone has his own magic wand. N magic wands was put in a line, numbered from 1 to n(Wand_i owned by wizard_i). After the meeting, n wizards will take a wand one ...原创 2018-04-07 21:51:33 · 153 阅读 · 0 评论 -
hannnnah_j’s Biological Test (lucas定理 )
hannnnah_j is a teacher in WL High school who teaches biology.One day, she wants to test m students, thus she arranges n different seats around a round table.In order to prevent cheating, she thinks t...原创 2017-11-12 21:17:00 · 316 阅读 · 0 评论 -
2 3 5 7的倍数
给出一个数N,求1至N中,有多少个数不是2 3 5 7的倍数。 例如N = 10,只有1不是2 3 5 7的倍数。 Input 输入1个数N(1 Output 输出不是2 3 5 7的倍数的数共有多少。 Sample Input 10 Sample Output 1 代码:#include #include using namespace std; typedef long lo原创 2018-01-23 14:23:25 · 365 阅读 · 0 评论 -
新生晚会(HDU2519)
Problem Description 开学了,杭电又迎来了好多新生。ACMer想为新生准备一个节目。来报名要表演节目的人很多,多达N个,但是只需要从这N个人中选M个就够了,一共有多少种选择方法? Input 数据的第一行包括一个正整数T,接下来有T组数据,每组数据占一行。 每组数据包含两个整数N(来报名的人数,1 Output 每组数据输出一个整数,每个输出占原创 2017-12-26 17:35:58 · 315 阅读 · 0 评论 -
Cube
Cowl is good at solving math problems. One day a friend asked him such a question: You are given a cube whose edge length is N, it is cut by the planes that was paralleled to its side planes into N *原创 2017-11-12 20:23:52 · 290 阅读 · 0 评论 -
不容易系列之(3)—— LELE的RPG难题
人称“AC女之杀手”的超级偶像LELE最近忽然玩起了深沉,这可急坏了众多“Cole”(LELE的粉丝,即"可乐"),经过多方打探,某资深Cole终于知道了原因,原来,LELE最近研究起了著名的RPG难题: 有排成一行的n个方格,用红(Red)、粉(Pink)、绿(Green)三色涂每个格子,每格涂一色,要求任何相邻的方格不能同色,且首尾两格也不同色.求全部的满足要求的涂法. 以原创 2017-09-11 16:27:27 · 166 阅读 · 0 评论 -
fireworks(杨辉三角+组合数学)
Problem DescriptionHmz likes to play fireworks, especially when they are put regularly.Now he puts some fireworks in a line. This time he put a trigger on each firework. With that trigger, each firewo...原创 2018-05-03 18:48:08 · 264 阅读 · 0 评论