题目地址:pid=5407">HDU 5407 题意:CRB有n颗不同的糖果,如今他要吃掉k颗(0<=k<=n),问k取0~n的方案数的最小公倍数是多少. 思路:首先做这道题我们须要必备的几个技能点. 1. LCM(C(n,0), C(n,1),-, C(n,n))=LCM(1,2,3,-n+1)/(n+1).额,这个有一篇证明Kummer定理 2.(1) 乘法逆元定义: 满足a*k≡1 (mod p)的k值就是a关于p的乘法逆元(a,p互质). (2)为什么要用乘法逆元: 当…
题目地址:HDU 5410 题意:有M元钱,N种礼物,若第i种礼物买x件的话.会有Ai*x+Bi颗糖果,现给出每种礼物的单位价格.Ai值与Bi值.问最多能拿到多少颗糖果. 思路:全然背包问题. dp[j][1]在当前物品时花钱为j的而且买过当前物品的最大值. dp[j][0]不买当前这件物品此前花钱为j的的最大值. 每种物品的价值随Ai线性变化,可是不随B[i]线性变化.B[i]仅是在第一次挑选第i件物品是才算入,其它时候均不算入. 所以我们能够写出状态转移方程: dp[j][0]=max(dp…
题目链接:pid=5414">点击打开链接 题目大意:有A.B两个字符串.如今有一种操作能够在A的随意一个字符x后面添加一个字符y(x.=y).问能不能将A变为B. 首先假设A能够变成B,那么A就一定是B的一个子序列,这个能够在O(n+m)的时间内算出. 假设A是B的子序列之后,推断添加的字符中是不是含有不能添加的情况,我们仅仅须要推断B从開始的一段连续的同样的字符串.是不是在A的开头也存在.假设存在,那么就是能够由A转化成B的. #include <cstdio> #incl…
http://acm.hdu.edu.cn/showproblem.php?pid=5414 题意:给定字符串s和t,可以在s里面选一个字符c,然后任选一个字符d(d!=c)将d插入到c的后面,问能不能将s变为t. 分析:只要前面t串连续的字符==s字符串,而且保证s是t的子串.本来想不通s:aabaa,t:aabaaaa,后面四个a怎么插,后来才想明白,后面的a都可以插在b后面,就可以了. CRB and String Time Limit: 2000/1000 MS (Java/Others…
CRB and String Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 65536/65536 K (Java/Others) Total Submission(s): 491    Accepted Submission(s): 186 Problem Description CRB has two strings s and t. In each step, CRB can select arbitrary charact…
pid=5288">http://acm.hdu.edu.cn/showproblem.php?pid=5288 Problem Description OO has got a array A of size n ,defined a function f(l,r) represent the number of i (l<=i<=r) , that there's no j(l<=j<=r,j<>i) satisfy ai mod aj=0,now…
Y Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 60    Accepted Submission(s): 20 Problem Description   Sample Input 4 1 2 1 3 1 4   Sample Output 1 Hint 1. The only set is {2,3,4}. 2. Please…
Sum Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 94    Accepted Submission(s): 41 Problem Description   Sample Input 2   Sample Output 2 Hint 1. For N = 2, S(1) = S(2) = 1. 2. The input fil…
Editor Time Limit: 3000/2000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 118    Accepted Submission(s): 38 Problem Description   Sample Input 8 I 2 I -1 I 1 Q 3 L D R Q 2   Sample Output 2 3 Hint The following…
Answers Time Limit: 2000/1000 MS (Java/Others)    Memory Limit: 131072/131072 K (Java/Others)Total Submission(s): 25    Accepted Submission(s): 16 Problem Description   Sample Input 2 4 2 2 2 1 0 1 2 3   Sample Output NO YES YES YES   Source 2013 Mul…