随笔分类 - 数学——组合数学
摘要:题意:给定N*M的矩阵,'*'表示可以通过,'#'表示不能通过,现在要找两条路径从[1,1]到[N,M]去,使得除了起点终点,没有交点。 思路:没有思路,就是裸题。 Lindström–Gessel–Viennot lemma a到b,c到d,两条路径完全没有交点的方案数=w[a,b]*w[c,d]
阅读全文
摘要:题意:A班有N个人,B班有M个人,现在要组成一个新的班级C班,为了公平,从AB班各抽相同人数的人。 现在求所有方案中,人数之和是多少。 思路:即求Σ k*C(N,k)*C(M,k); 先忽略这个外层的k,看看两个组合数乘积的和怎么求。 显然Σ C(N,k)*C(M,k)=C(N+M,N); 因为C(
阅读全文
摘要:As everyone known, The Monkey King is Son Goku. He and his offspring live in Mountain of Flowers and Fruits. One day, his sons get n peaches. And ther
阅读全文
摘要:You are running for a governor in a small city in Russia. You ran some polls and did some research, and for every person in the city you know whom he
阅读全文
摘要:Permutation p is an ordered set of integers p1, p2, ..., pn, consisting of n distinct positive integers, each of them doesn't exceed n. We'll denote t
阅读全文
摘要:In an attempt to make peace with the Mischievious Mess Makers, Bessie and Farmer John are planning to plant some flower gardens to complement the lush
阅读全文
摘要:As Gerald, Alexander, Sergey and Gennady are already busy with the usual New Year chores, Edward hastily decorates the New Year Tree. And any decent N
阅读全文
摘要:4550: 小奇的博弈 Description 这个游戏是在一个1*n的棋盘上进行的,棋盘上有k个棋子,一半是黑色,一半是白色。最左边是白色棋子,最右边 是黑色棋子,相邻的棋子颜色不同。 小奇可以移动白色棋子,提比可以移动黑色的棋子,它们每次操作可以移动1到d个棋子。每当移动某一个棋子时, 这个棋子
阅读全文
摘要:题意:略。 思路:网上是用卷积或者做的,不太会。 因为上一题莫比乌斯有个类似的部分,所以想到了每个素因子单独考虑。 我们用C(x^p)表示p次减少分布在K次减少里的方案数,由隔板法可知,C(x^p)=C(K+p-1,K-1); 而且满足C(x)有积性,即gcd(x,y)==1时,有C(x*y)=C(
阅读全文
摘要:题意:T组数据,给次给出N,M,K,多少种方案,用[0,N-1]范围的数,表示一个M排列,其和为K; 思路:隔板法,不限制[0,N-1]的时候答案是C(M+K-1,M-1);那么我们减去至少一个>=N,加上至少两个>=N....即可得到答案。 假设至少一个隔板里的数大于大于N,我们从这个隔板里抽出N
阅读全文
摘要:一个包含四个点的完全图,可以在任意节点出发,可以在任意节点结束,给出每个点被经过的次数,求有多少种合法的遍历序列。如果两个序列至少有一位是不同的,则认为它们不相同。 Input Sample Output 题意:给a个A,b个B,c个C,d个D,求有少种排列,使得相邻的两个不同。 思路:用容斥来做,
阅读全文
摘要:【BZOJ3622】已经没有什么好害怕的了 Description Input Output Sample Input 4 2 5 35 15 45 40 20 10 30 Sample Output 4 HINT 输入的2*n个数字保证全不相同。 输入的2*n个数字保证全不相同。 题意:给定a数组
阅读全文
摘要:There are n n apples on a tree, numbered from 1 1 to n n . Count the number of ways to pick at most m m apples. InputThe first line of the input conta
阅读全文
摘要:Count the number of distinct sequences a1, a2, ..., an (1 ≤ ai) consisting of positive integers such that gcd(a1, a2, ..., an) = x and . As this numbe
阅读全文
摘要:Lakhesh loves to make movies, so Nephren helps her run a cinema. We may call it No. 68 Cinema. However, one day, the No. 68 Cinema runs out of changes
阅读全文
摘要:对于一个 11 到 nn 的排列 p1,p2,⋯,pnp1,p2,⋯,pn ,我们可以轻松地对于任意的 1≤i≤n1≤i≤n 计算出 (li,ri)(li,ri) ,使得对于任意的 1≤L≤R≤n1≤L≤R≤n 来说 min(pL,pL+1,⋯,pR)=pimin(pL,pL+1,⋯,pR)=pi
阅读全文
摘要:Rastas's has been given a number n. Being weak at mathematics, she has to consider all the numbers from 1 to 2n - 1 so as to become perfect in calcula
阅读全文
摘要:Devu wants to decorate his garden with flowers. He has purchased n boxes, where the i-th box contains fi flowers. All flowers in a single box are of t
阅读全文
摘要:给定n,(n<=10^3),然后输入n的数a[i],(a[i]<=1e10),求ans=(a1+a2+a3...an)! / (a1!*a2!*a3!...an!) 的结果的最一位数。 适用问题,n种物品,求全排种类,结果%10。 猜想1,斯特林公式,斯特林公式虽然误差越来越小,但是最后一位的误差是
阅读全文
摘要:>On the way to the next secret treasure hiding place, the mathematician discovered a cave unknown to the map. The mathematician entered the cave becau
阅读全文