题目:钱数拼凑,面值为1,5,10,25,求组成n面值的最大钱币数。
分析:dp,01背包。需要进行二进制拆分,否则TLE,利用数组记录每种硬币的个数,方便更新。
写了一个 多重背包的 O(NV)反而没有拆分快。囧,最后利用了状态压缩优化 90ms;
把 1 cents 的最后处理,其他都除以5,状态就少了5倍了。
说明:貌似我的比大黄的快...
分类:
其他好文 时间:
2014-10-11 00:49:44
阅读次数:
392
Description
Tingting wants to draw and stucco N squares with N different colors full of the base line of a wall.
Give you the number of squares, the length of the wall, the minimum size and the ...
分类:
其他好文 时间:
2014-10-10 23:42:34
阅读次数:
344
http://acm.zju.edu.cn/onlinejudge/showProblem.do?problemId=1317
给出一个n*m的矩阵(n
构造出转移矩阵,上一行向下一行的转移矩阵,因为m
因为n特别大,要用到大数。我存矩阵的时候开始定义的大数类,一直T,改成了int型才A,1s+,难道大数类这么慢么,5s都过不了。
import java....
分类:
其他好文 时间:
2014-10-10 23:26:14
阅读次数:
230
Shoot the Bullet
Time Limit: 2 Seconds Memory Limit: 32768 KB Special Judge
Gensokyo is a world which exists quietly beside ours, separated by a mystical border. It is a utopia where h...
分类:
其他好文 时间:
2014-10-10 18:30:44
阅读次数:
266
题目:在m*n的地板上铺上相同的1*2的地板砖,问有多少种铺法。
分析:dp,组合,计数。经典dp问题,状态压缩。
状态:设f(i,j)为前i-1行铺满,第i行铺的状态的位表示为j时的铺砖种类数;
转移:因为只能横铺或者竖铺,那么一个砖块铺之前的状态只有两种;
且如果当前竖放会对下一行产生影响,建立...
分类:
其他好文 时间:
2014-10-10 13:55:34
阅读次数:
214
题目:javaman来到了一个城市,这里有很多长着金币的树,每棵树每晚还会结出新的金币,
现在他每天白天只能砍一棵树,最多在这里呆m天,求能得到的最大金币数。
分析:贪心+dp,二维01背包。如果砍树的集合确定,那一定按照b递增的顺序砍,因此排序后背包。
说明:(2011-11-02 05:49)。
#include
#include
#include
#de...
分类:
其他好文 时间:
2014-10-10 00:59:35
阅读次数:
236
Recently, researchers on Mars have discovered N powerful atoms. All of them are different. These atoms have some properties. When two of these atoms collide, one of them disappears and a lot of power ...
分类:
其他好文 时间:
2014-10-10 00:09:23
阅读次数:
206
Alice's Print ServiceTime Limit:2 Seconds Memory Limit:65536 KBAlice is providing print service, while the pricing doesn't seem to be reasonable, so p...
分类:
其他好文 时间:
2014-10-09 22:55:28
阅读次数:
163
题意:一些机枪彼此不能在同一行和同一列,但是由于有墙的阻隔,能保证子弹无法穿透,即可以同行同列,现问如果说给了一个n*n(n#include using namespace std;int n,best;char map[4][4];int canput(int row,int col){ int....
分类:
其他好文 时间:
2014-10-09 22:10:47
阅读次数:
233
CollisionTime Limit:2 Seconds Memory Limit:65536 KB Special JudgeThere's a round medal fixed on an ideal smooth table, Fancy is trying to throw some c...
分类:
其他好文 时间:
2014-10-09 20:32:37
阅读次数:
317