摘要: 在这之前做过九度的题,题目只要求判断能否构成那样的划分,没有让求不同划分的个数,所以dfs就能过,这题dfs到36时超时,各种剪枝都无效。。后来看的题解,原来是DP。。。学习了先贴DP代码,再贴DFS的超时代码 1 /* ID:linyvxi1 2 PROB:subset 3 LANG:C++ 4 */ 5 #include <stdio.h> 6 int main() 7 { 8 freopen("subset.in","r",stdin); 9 freopen("subset.out","w",st 阅读全文
posted @ 2012-03-06 21:34 linyvxiang 阅读(222) 评论(0) 推荐(0) 编辑
摘要: 暴力 1 /* ID:linyvxi1 2 PROB:hamming 3 LANG:C++ 4 */ 5 #include <stdio.h> 6 #include <math.h> 7 #include <stdlib.h> 8 int N,B,D; 9 int max_search_num;10 int final_result[130];11 int num_found;12 13 bool check(int next)14 {15 int s=0;16 for(;s<num_found;s++){17 int temp;18 temp=ne. 阅读全文
posted @ 2012-03-06 20:08 linyvxiang 阅读(132) 评论(0) 推荐(0) 编辑