[CF896D]Nephren Runs a Cinema 题意:一个序列中有n格数,每个数可能是0,1,-1,如果一个序列的所有前缀和都>=0且总和$\in [L,R]$,那么我们称这个序列是合法的.求合法序列的个数%P. n,L,R<=100000,P<=2*10^9 题解:先不考虑0的数,那么总数显然就是卡特兰数的变形.我们将卡特兰数转换成在二维平面上,从(0,0)走到(a,b),且不越过直线x=y的方案数.因为每个越过x=y的方案都可以转化成从(-1,1)走到(a,b)的方案,所…
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 (they don't have 50-yuan notes currently), but Nephren still wants to start their business. (Assume…
CF896D Nephren Runs a Cinema 题意 售票员最开始没有纸币,每次来一个顾客可以给她一张.拿走她一张或不操作.求出不出现中途没钱给的情况 \(n\) 名顾客后剩余钱数在 \(l\sim r\) 的方案数. 思路 这是我们一道模拟赛题. 解法 1:套路组合计数.先不考虑不操作的顾客,那么就相当于是求二维平面不过一条直线到达一点的方案数.直接枚举操作顾客数,用组合数减去另外一个组合数然后乘上所有顾客中选这些顾客的方案数即可. 解法 2:暴力动态规划.每次从至多三个方向转移.…
题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=1023 Train Problem II Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others)Total Submission(s): 12035    Accepted Submission(s): 6422 Problem Description As we all know the…
option=com_onlinejudge&Itemid=8&category=471&page=show_problem&problem=4224" style="">题目链接:uva 1478 - Delta Wave 题目大意:对于每一个位置来说,能够向上,水平,向下.坐标不能位负.每次上下移动最多为1. 给定n问说有多少种不同的图.结果对10100取模. 解题思路:由于最后都要落回y=0的位置,所以上升的次数和下降的次数是同样的…
Robot Time Limit: 12000/6000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others)Total Submission(s): 483    Accepted Submission(s): 244 Problem Description There is a robot on the origin point of an axis.Every second, the robot can move rig…
Description lxhgww最近接到了一个生成字符串的任务,任务需要他把n个1和m个0组成字符串,但是任务还要求在组成的字符串中,在任意的前k个字符中,1的个数不能少于0的个数.现在lxhgww想要知道满足要求的字符串共有多少个,聪明的程序员们,你们能帮助他吗? Input 输入数据是一行,包括2个数字n和m Output 输出数据是一行,包括1个数字,表示满足要求的字符串数目,这个数可能会很大,只需输出这个数除以20100403的余数 Sample Input 2 2 Sample O…
题意:求n个1,m个-1组成的所有序列中,最大前缀之和. 首先引出这样一个问题:使用n个左括号和m个右括号,组成的合法的括号匹配(每个右括号都有对应的左括号和它匹配)的数目是多少? 1.当n=m时,显然答案为卡特兰数$C_{2n}^{n}-C_{2n}^{n+1}$ 2.当n<m时,无论如何都不合法,答案为0 3.当n>m时,答案为$C_{n+m}^{n}-C_{n+m}^{n+1}$,这是一个推论,证明过程有点抽象,方法是把不合法的方案数等价于从(0,-2)移动到(n+m,n-m)的方案数,…
Problem Description The "Harry Potter and the Goblet of Fire" will be on show in the next few days. As a crazy fan of Harry Potter, you will go to the cinema and have the first sight, won't you? Suppose the cinema only has one ticket-office and…
Buy the Ticket Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/32768 K (Java/Others) Total Submission(s): 4726    Accepted Submission(s): 1993 Problem Description The "Harry Potter and the Goblet of Fire" will be on show in the nex…