题目链接:
http://acm.timus.ru/problem.aspx?space=1&num=1114
1114. Boxes
Time limit: 0.6 second
Memory limit: 64 MB
N boxes are lined up in a sequence (1 ≤ N ≤ 20). You have A red ball...
分类:
其他好文 时间:
2014-05-09 21:58:58
阅读次数:
471
很好的一道动态规划法题目。
注意:
1 行列别搞错了,要很细心一点一点对起来
2 要以边线思考,不要以方块来计算, N*M个方块就成了(N+1)*(M+1)条交叉线了,最下面和最左边的线就方便初始化了
3 注意C++的四舍五入的方法
动态规划的状态转移方程:
if (A[y][x]) B[x] = t + 1.414213562;
else B[x] = min(B[x-1], B[x]) + 1 ;
A[y][x]表示是否有对角线,有对角线必定是走对角线的。...
分类:
其他好文 时间:
2014-04-30 22:21:38
阅读次数:
369
本题可以使用长整形来记录数据的,因为最长不过10^8,但是如果把这题当做是无穷大数来做的话,难度指数就直线上升了。
这里给出使用string来做无穷大减法的解法。
要处理的问题:
1 string大小比较问题,不能使用原始的<号
2 如何进位的问题
3 符号问题,因为这里只求差异就可以了,所以返回绝对值就够了。
这样做本题还是有一定难度, 而且可以锻炼到一些高级点的知识的运用,挺好。...
分类:
其他好文 时间:
2014-04-29 13:46:22
阅读次数:
277
Our chemical biologists have invented a new very useful form of life called stripies (in fact, they were first called in Russian - polosatiki, but the scientists had to invent an English
name to app...
分类:
其他好文 时间:
2014-04-29 13:45:22
阅读次数:
309
1D people lived in a 1D country. Everything in the country was one-dimensional, and everything was simple and clear: just one axis and two directions — forward and backward. Even a 1D world has proble...
分类:
其他好文 时间:
2014-04-29 13:44:22
阅读次数:
284
At the start of each school year, a very important event happens at Hogwarts. Each of the first-year wizards and witches is assigned to one of the four Hogwarts houses. The bravest children are put
...
分类:
其他好文 时间:
2014-04-29 13:38:20
阅读次数:
459
又是一个新的算法,原来可以这样查找的。
我的一句话理解的思想:
计算可以抵消的数量,那么如果一个数出现的次数超过半那么最终这个数肯定不会被抵消完。
这个思想叫 Moore’s Voting Algorithm
有了这个思想武器之后,程序就可以写的很简单,可以很清楚看到怎么实现的,
参考资料可以看:...
分类:
其他好文 时间:
2014-04-29 13:22:22
阅读次数:
260
The blonde Angela has a new whim: internet chats. Of course, as any blonde, she writes her messages using the upper case. You are the moderator of Angela's favorite chat and you're fed up with her upp...
分类:
其他好文 时间:
2014-04-29 13:17:21
阅读次数:
293
实现一个登陆系统。
思路:
1 使用map,在map中的就是已经注册的了
2 使用数据结构保存用户名,是否登陆和密码
3 使用if else判断处理第一个字符串-命令
类似很多人都写的什么图书馆管理系统,什么信息系统之类的登陆控制管理,都是很简单的东西,一步一步写就不会错了,完成速度相当于打字速度。...
分类:
其他好文 时间:
2014-04-29 13:16:21
阅读次数:
298
Mrs Little likes digits most of all. Every year she tries to make the best number of the year. She tries to become more and more intelligent and every year studies a new digit. And the number she make...
分类:
其他好文 时间:
2014-04-29 13:13:21
阅读次数:
309