
组合数学
组合数学
Guuuuuu老师儿
当初的算法竞赛题目博客的留言评论就不回复了,时间太久已经忘干净了,抱歉~
展开
专栏收录文章
- 默认排序
- 最新发布
- 最早发布
- 最多阅读
- 最少阅读
-
Eddy's AC难题 HDU - 2200 (求组合数)
Eddy's AC难题 HDU - 2200 Eddy是个ACMer,他不仅喜欢做ACM题,而且对于Ranklist中每个人的ac数量也有一定的研究,他在无聊时经常在纸上把Ranklist上每个人的ac题目的数量摘录下来,然后从中选择一部分人(或者全部)按照ac的数量分成两组进行比较,他想使第一组中的最小ac数大于第二组中的最大ac数,但是这样的情况会有很多,聪明的你知道这样的情况原创 2017-11-08 18:32:09 · 300 阅读 · 0 评论 -
cf 997c Sky Full of Stars(组合数+容斥原理)
Sky Full of StarsOn one of the planets of Solar system, in Atmosphere University, many students are fans of bingo game.It is well known that one month on this planet consists of n2 days, so calen...原创 2018-08-21 13:58:24 · 863 阅读 · 0 评论 -
Visible Lattice Points(莫比乌斯反演经典)
Visible Lattice PointsConsider a N*N*N lattice. One corner is at (0,0,0) and the opposite one is at (N,N,N). How many lattice points are visible from corner at (0,0,0) ? A point X is visible from po...原创 2018-08-20 19:53:30 · 725 阅读 · 0 评论 -
Problem G. Cyclic HDU - 6432(容斥原理)
Problem G. Cyclic HDU - 6432 Count the number of cyclic permutations of length n with no continuous subsequence [i, i + 1 mod n].Output the answer modulo 998244353. Input The first line of ...原创 2018-08-27 16:41:03 · 405 阅读 · 2 评论 -
Gcd(莫比乌斯反演)
Gcd给定整数N,求1<=x,y<=N且Gcd(x,y)为素数的数对(x,y)有多少对.Input一个整数NOutput如题Sample Input 4Sample Output 4 Hinthint对于样例(2,2),(2,4),(3,3),(4,2)1<=N<=10^7题意:略分析:...原创 2018-08-23 08:23:05 · 691 阅读 · 0 评论 -
Mophues(莫比乌斯反演+分段)
Mophues As we know, any positive integer C ( C >= 2 ) can be written as the multiply of some prime numbers: C = p1×p2× p3× ... × pkwhich p1, p2 ... pk are all prime numbers.For example, if C...原创 2018-08-22 20:02:36 · 466 阅读 · 0 评论 -
Sum Of Gcd(欧拉函数+莫队算法详解)
Sum Of Gcd Given you a sequence of number a 1, a 2, ..., a n, which is a permutation of 1...n.You need to answer some queries, each with the following format:Give you two numbers L, R, you should ...原创 2018-08-15 21:26:46 · 571 阅读 · 0 评论 -
How many integers can you find(容斥原理)
How many integers can you find Now you get a number N, and a M-integers set, you should find out how many integers which are small than N, that they can divided exactly by any integers in the set....原创 2018-08-08 11:02:23 · 463 阅读 · 0 评论 -
Character Encoding HDU - 6397(容斥原理解决方程解个数经典问题详解)
Character Encoding HDU - 6397In computer science, a character is a letter, a digit, a punctuation mark or some other similar symbol. Since computers can only process numbers, number codes are used t...原创 2018-08-21 13:59:58 · 1844 阅读 · 0 评论 -
Primes in GCD Table SPOJ - PGCD(莫比乌斯反演+分段)
Primes in GCD Table SPOJ - PGCDJohnny has created a table which encodes the results of some operation -- a function of two arguments. But instead of a boring multiplication table of the sort you lea...原创 2018-08-21 20:29:47 · 312 阅读 · 1 评论 -
Counting UVA - 10198(线性递推式)
Counting UVA - 10198题意:Gustavo数数时总是把1和4搞混,他认为4只是1的另外一种写法。给出一个整数n,Gustavo想知道有多少个数的数字之和恰好为n。例如,当n=2时,有5个数:11、14、41、44、2。分析:设dp[n]表示加和为n的组合的个数那么很明显这些组合中应该含有含1的组合,那么去掉这个1的话就是dp[n-1]的个数加上一个1,同理含2 的话有d...原创 2018-09-22 09:33:02 · 384 阅读 · 0 评论 -
Sum HDU - 4407(容斥定理)
Sum HDU - 4407XXX is puzzled with the question below:1, 2, 3, …, n (1<=n<=400000) are placed in a line. There are m (1<=m<=1000) operations of two kinds.Operation 1: among the x-th numb...原创 2018-09-21 13:30:04 · 333 阅读 · 0 评论 -
Instability HDU - 5917(Ramsey定理)
Instability HDU - 5917Long long ago, there was a prosperous kingdom which consisted of n cities and every two cites were connected by an undirected road.However, one day a big monster attacked the k...原创 2018-09-25 17:11:25 · 379 阅读 · 0 评论 -
Puzzled Elena HDU - 5468(dfs序+容斥定理)
Puzzled Elena HDU - 5468 Since both Stefan and Damon fell in love with Elena, and it was really difficult for her to choose. Bonnie, her best friend, suggested her to throw a question to them, and s...原创 2018-09-14 19:56:12 · 295 阅读 · 0 评论 -
HDU 4675 GCD of Sequence(数论+组合数学||莫比乌斯反演)
GCD of Sequence Alice is playing a game with Bob.Alice shows N integers a 1, a 2, …, a N, and M, K. She says each integers 1 ≤ a i ≤ M.And now Alice wants to ask for each d = 1 to M, how many diff...原创 2018-08-13 20:03:50 · 411 阅读 · 0 评论 -
2018ACM-ICPC徐州赛区网络赛: A. Hard to prepare(递推)
2018ACM-ICPC徐州赛区网络赛: A. Hard to prepare(递推)After Incident, a feast is usually held in Hakurei Shrine. This time Reimu asked Kokoro to deliver a Nogaku show during the feast. To enjoy the show, every...原创 2018-09-11 09:36:09 · 449 阅读 · 0 评论 -
ACM-ICPC 2018 沈阳赛区网络预赛 G.Spare Tire (容斥)
Spare TireA sequence of integer {an}\lbrace a_n \rbrace{an} can be expressed as:an={0,n=02,n=13an−1−an−22+n+1,n>1\displaystyle a_n = \left{ 0,2,3an−1−an−22+n+1,n=0n=1n>10,n=02,n=13an−1−an−2...原创 2018-09-09 10:09:12 · 309 阅读 · 3 评论 -
Jesus Is Here HDU - 5459(思维+数学递推)
Jesus Is Here HDU - 5459I’ve sent Fang Fang around 201314 text messages in almost 5 years. Why can’t she make sense of what I mean? But Jesus is here!" the priest intoned.Show me your messages.” F...原创 2018-08-30 14:23:17 · 256 阅读 · 0 评论 -
GuGuFishtion HDU - 6390(莫比乌斯反演+线性求逆元)
GuGuFishtion HDU - 6390Today XianYu is too busy with his homework, but the boring GuGu is still disturbing him!!!!!! At the break time, an evil idea arises in XianYu’s mind. ‘Come on, you xxxxxxx ...原创 2018-08-15 10:48:39 · 596 阅读 · 2 评论 -
Problem B. Harvest of Apples HDU - 6333(莫队算法+组合数)
Problem B. Harvest of Apples HDU - 6333There are n apples on a tree, numbered from 1 to n. Count the number of ways to pick at most m apples. Input The first line of the input contains a...原创 2018-08-02 15:00:47 · 411 阅读 · 0 评论 -
fireworks(组合数取模,第八届山东省赛)
fireworksProblem 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, ea...原创 2018-05-03 19:37:06 · 190 阅读 · 0 评论 -
GCD Expectation ZOJ - 3868 (容斥原理+快速幂)
GCD Expectation ZOJ - 3868 Edward has a set of n integers {a1, a2,...,an}. He randomly picks a nonempty subset {x1, x2,…,xm} (each nonemp...原创 2018-04-25 19:54:23 · 306 阅读 · 0 评论 -
Wand FZU - 2282 (组合数取模+错排公式)
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...原创 2018-04-06 17:11:48 · 310 阅读 · 0 评论 -
Prefix Sums CodeForces - 837F(思维+二分+组合数)
Prefix Sums CodeForces - 837FConsider the function p(x), where x is an array of m integers, w...原创 2018-04-05 14:45:11 · 287 阅读 · 0 评论 -
Code POJ - 1850 (组合数学)
Code POJ - 1850 Transmitting and memorizing information is a task that requires different coding systems for the best use of the available space. A well known system is that one where a number原创 2017-11-16 09:32:38 · 505 阅读 · 0 评论 -
xiaoxin juju needs help HDU - 5651 (有重复的全排列,逆元)
xiaoxin juju needs helpHDU - 5651As we all known, xiaoxin is a brilliant coder. He knew **palindromic** strings when he was only a six grade student at elementry school.This summer he was wo原创 2017-11-15 20:07:45 · 368 阅读 · 0 评论 -
Xiao Ming's Hope HDU - 4349(Lucas定理)
Xiao Ming's HopeHDU - 4349Xiao Ming likes counting numbers very much, especially he is fond of counting odd numbers. Maybe he thinks it is the best way to show he is alone without a girl friend.原创 2017-11-08 18:47:24 · 314 阅读 · 0 评论 -
不容易系列之一 HDU - 1465 (错排公式)
不容易系列之一 HDU - 1465 大家常常感慨,要做好一件事情真的不容易,确实,失败比成功容易多了! 做好“一件”事情尚且不易,若想永远成功而总从不失败,那更是难上加难了,就像花钱总是比挣钱容易的道理一样。 话虽这样说,我还是要告诉大家,要想失败到一定程度也是不容易的。比如,我高中的时候,就有一个神奇的女生,在英语考试的时候,竟然把40个单项选择题全部做错了!大家都学过原创 2017-11-08 18:33:06 · 204 阅读 · 0 评论 -
HEX(第八届山东省赛,思维+组合数)
HEXProblem 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 ...原创 2018-05-03 20:31:31 · 213 阅读 · 0 评论 -
有重复组合公式及其证明方法
有重复组合公式如下:若在n个元素中有重复的选择r个元素的公式:Crn+r−1Cn+r−1rC_{n+r-1}^{r}这个公式的证明有很多种方法,这里只选取最容易理解的方式进行证明:证明如下:把n个元素当成n个顺序摆放的盒子,r是r个完全相同的球,这样从n个元素中有重复取r个元素的方法就转化成,把r个同质球放入n个盒子的方法为什么可以这样呢,想想,把一个球放到第i个盒...原创 2018-07-21 15:42:42 · 24354 阅读 · 6 评论 -
POJ 3904 Sky Code(容斥原理)
Sky CodeStancu likes space travels but he is a poor software developer and will never be able to buy his own spacecraft. That is why he is preparing to steal the spacecraft of Petru. There is only o...原创 2018-08-10 20:53:45 · 1226 阅读 · 1 评论 -
bookshelf HDU - 6363(数论结论+莫比乌斯反演)
bookshelf HDU - 6363Patrick Star bought a bookshelf, he named it ZYG !!Patrick Star has N book .The ZYG has K layers (count from 1 to K) and there is no limit on the capacity of each layer !No...原创 2018-08-10 16:31:19 · 541 阅读 · 0 评论 -
Yet Another Problem On a Subsequence(dp+组合数)
Yet Another Problem On a SubsequenceThe sequence of integers a1,a2,…,ak is called a good array if a1=k−1 and a1>0. For example, the sequences [3,−1,44,0],[1,−99] are good arrays, and the sequence...原创 2018-08-01 08:48:20 · 449 阅读 · 0 评论 -
Coprime HDU3388(容斥原理+二分查找)
Coprime Please write a program to calculate the k-th positive integer that is coprime with m and n simultaneously. A is coprime with B when their greatest common divisor is 1. Input The firs...原创 2018-08-09 20:48:43 · 282 阅读 · 0 评论 -
hdu 1695 GCD(莫比乌斯反演经典入门||容斥原理+欧拉函数)
GCD Given 5 integers: a, b, c, d, k, you're to find x in a...b, y in c...d that GCD(x, y) = k. GCD(x, y) means the greatest common divisor of x and y. Since the number of choices may be very large, ...原创 2018-08-09 18:24:36 · 677 阅读 · 0 评论 -
GCD and LCM(质因子分解+组合数学)
GCD and LCM Given two positive integers G and L, could you tell me how many solutions of (x, y, z) there are, satisfying that gcd(x, y, z) = G and lcm(x, y, z) = L?Note, gcd(x, y, z) means the grea...原创 2018-07-31 19:02:47 · 655 阅读 · 0 评论 -
HDU 2841 Visible Trees(容斥原理+解释)
Visible Trees There are many trees forming a m * n grid, the grid starts from (1,1). Farmer Sherlock is standing at (0,0) point. He wonders how many trees he can see.If two trees and Sherlock are ...原创 2018-08-09 11:09:34 · 705 阅读 · 0 评论 -
Pave the Parallelepiped(有重复组合公式+状态压缩)
Pave the ParallelepipedYou are given a rectangular parallelepiped with sides of positive integer lengths A, B and C.Find the number of different groups of three integers (a , b, c) such that 1≤...原创 2018-07-21 16:39:19 · 969 阅读 · 4 评论 -
Expressions UVA - 10157(组合数学+递推)
Expressions UVA - 10157题目:给你n个括号,求合法的匹配中,深度不超过d的组合数。分析:组合,计数,dp,大整数。这个题目很像卡特兰数,不过深度有限制,可以利用卡特兰数的递推公式求解;设DP(k,d)为k对括号形成深度不超过d的合法匹配方法数;则有:DP(k,d)= Σ(DP(i,d-1)*DP(k-1-i,d)) { i 取0到 k-1 }(按卡特兰数递推,...原创 2018-09-23 09:09:10 · 406 阅读 · 0 评论