摘要:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1770 这是这次BSG白山极客挑战赛的B题。设p(i, j)表示节点个数为i,高度为j的AVL树的个数。 那么,对于1 <= k <= i-1 p[i][j] += p[k]
阅读全文
摘要:http://bestcoder.hdu.edu.cn/contests/contest_show.php?cid=690 A题: 给定字符串,求任意区间的Hash值。 根据题目给定的Hash方式,属于乘法类型,那么就可以预处理出所有的乘法前缀,然后利用逆元,就可以得到任意区间的Hash值。 不过在
阅读全文
摘要:题目链接:http://219.244.176.199/JudgeOnline/problem.php?id=1213 这是这次微软实习面试的一道题,当时只相出了一个2n的做法,面试官让我优化成n的做法。不过当时没想出来,最后面试官提示到了最后才恍然大悟。 题目大意就是在一个环上有n个加油站,已知第
阅读全文
摘要:题目链接:http://gdutcode.sinaapp.com/problem.php?cid=1031&pid=4 这个题目自然会考虑到去讨论最长或者最短的板子。 笔上大概模拟一下的话,就会知道,假设最长的板子是r,0和n+1位置上都是高度为0的板子,那么对于[0, r-1]中的最长板子rr,r
阅读全文
摘要:题目链接:http://gdutcode.sinaapp.com/problem.php?cid=1031&pid=2 题目由于要找对称的路径,那么狠明显可以把右下角的每一块加到左上角对应的每一块上。然后就变成从左上角走到对角线的最短路径的个数。 先跑一遍最短路径得到p(i, j)从起点到(i, j
阅读全文
摘要:http://hihocoder.com/problemset/problem/1290 这题是这次微软笔试的第三题,过的人比第一题少一点,这题一眼看过去就是动态规划,不过转移方程貌似不是很简单,调试了比较久才正确,不过好在是1A,但是最后只留了一个小时多一点给B题,也导致了B题最后也没能AC掉。首
阅读全文
摘要:http://acm.hdu.edu.cn/showproblem.php?pid=5640 这题有点辗转相除的意思。基本没有什么坑点。 代码: http://acm.hdu.edu.cn/showproblem.php?pid=5641 这题坑点有点多,3A。。首先任意一条连线,需要判断中间有
阅读全文
摘要:题目链接:https://icpcarchive.ecs.baylor.edu/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=5159题目大意是就是n个人进行两两的比赛,胜一局得A分,平局B分,败局C分。然后取...
阅读全文
摘要:题目链接:http://acm.uestc.edu.cn/#/problem/show/1217题目大意就是求一个序列里面长度为m的递增子序列的个数。首先可以列出一个递推式p(len,i)=sum(p(len-1,j))(a[j]#include #include #include #include...
阅读全文
摘要:DescriptionAsequenceconsistingofonedigit,thenumber1isinitiallywrittenintoacomputer.Ateachsuccessivetimestep,thecomputersimultaneouslytranformseachdigi...
阅读全文
摘要:DescriptionAsweallknowtheTrainProblemI,thebossoftheIgnatiusTrainStationwanttoknowifallthetrainscomeinstrict-increasingorder,howmanyordersthatallthetra...
阅读全文
摘要:The United Nations has decided to build a new headquarters in Saint Petersburg, Russia. It will have a form of a rectangular parallelepiped and will c...
阅读全文
摘要:Problem DescriptionAs we know, sequence in the form ofan=a1+(n−1)dis called arithmetic progression and sequence in the form ofbn=b1qn−1(q>1,b1≠0)is ca...
阅读全文
摘要:Sample Input956781131205199312199401201314Sample OutputCase #1: 5Case #2: 16Case #3: 88Case #4: 352Case #5: 318505405Case #6: 391786781Case #7: 133875...
阅读全文
摘要:DescriptionThe 11th Zhejiang Provincial Collegiate Programming Contest is coming! As a problem setter, Edward is going to arrange the order of the pro...
阅读全文
摘要:DescriptionThe 11th Zhejiang Provincial Collegiate Programming Contest is coming! As a problem setter, Edward is going to arrange the order of the pro...
阅读全文
摘要:Description今年暑假杭电ACM集训队第一次组成女生队,其中有一队叫RPG,但做为集训队成员之一的野骆驼竟然不知道RPG三个人具体是谁谁。RPG给他机会让他猜猜,第一次猜:R是公主,P是草儿,G是月野兔;第二次猜:R是草儿,P是月野兔,G是公主;第三次猜:R是草儿,P是公主,G是月野兔;.....
阅读全文
摘要:Description "Well, it seems the first problem is too easy. I will let you know how foolish you are later." feng5166 says. "The second problem is, give...
阅读全文
摘要:ProblemDescriptionTeacherMaihasnnumbersa1,a2,⋯,anandn−1operators("+","-"or"*")op1,op2,⋯,opn−1,whicharearrangedintheforma1op1a2op2a3⋯an.Hewantstoerasen...
阅读全文
摘要:DescriptionAssuming a finite – radius “ball” which is on an N dimension is cut with a “knife” of N-1 dimension. How many pieces will the “ball” be cut...
阅读全文