摘要: 一上午才看懂一个:动态规划是用空间换时间的一种方法的抽象。其关键是发现子问题和记录其结果。然后利用这些结果减轻运算量。比如01背包问题。因为背包最大容量M未知。所以,我们的程序要从1到M一个一个的试。比如,开始任选N件物品的一个。看对应M的背包,能不能放进去,如果能放进去,并且还有多的空间,则,多出来的空间里能放N-1物品中的最大价值。怎么能保证总选择是最大价值呢?看下表。测试数据:10,33,4... 阅读全文
posted @ 2013-03-23 19:32 码代码的猿猿 阅读(193) 评论(0) 推荐(0) 编辑
摘要: 写了个特别挫的: #include #include #include using namespace std;int main(){ int llc=0; cin>>llc;for(int j=0;j>str; H=(str[0]-48)*10+(str[1]-48); M=(str[3]-48)*10+(str[4]-48); S=(str[6]-48)*10+(... 阅读全文
posted @ 2013-03-23 08:03 码代码的猿猿 阅读(188) 评论(0) 推荐(0) 编辑
摘要: qsort(T,n,sizeof(Note),cmp); int ans=1; int me=T[0].e; int i=1; while(ime) { me=T.e; ans++; } i++; } 阅读全文
posted @ 2013-03-23 00:50 码代码的猿猿 阅读(107) 评论(0) 推荐(0) 编辑