上一页 1 ··· 35 36 37 38 39 40 41 42 43 ··· 99 下一页

2011年8月12日

hdu 1572 下沙小面的(2)

摘要: 这题和necklace 类似。。#include <stdio.h>#include <string.h>#include <stdlib.h>#include <algorithm>using namespace std;int map[40][40];int dis[40];int hash[40];int N, M, k, sum;void DFS( int S, int n, int s){ int j; if (n == k) { if (sum > S) sum = S; return ; } for(j = 0; j < 阅读全文

posted @ 2011-08-12 10:57 more think, more gains 阅读(301) 评论(0) 推荐(0) 编辑

变形课

摘要: 这题我的思路是。。把字符串转换为矩阵。。然后我写dfs时。。有个条件。。if ( i == 'm' -a') return 1;最后老是错误。。深搜是有很多层。。调用了很多次函数。。 return 1只会结束当前调用的函数。。写有返回值的递归函数要小心啊。最后改成 void 型。。AC 了。。#include <stdio.h>#include <string.h>#include <stdlib.h>int map[1001][1001];int hash[1001][1001];const int inf = 0x7f7f7f7f 阅读全文

posted @ 2011-08-12 09:42 more think, more gains 阅读(261) 评论(0) 推荐(0) 编辑

2011年8月11日

sum it up hdu 1258

摘要: Sum It UpTime Limit : 2000/1000ms (Java/Other)Memory Limit : 65536/32768K (Java/Other)Total Submission(s) : 1Accepted Submission(s) : 1Font: Times New Roman | Verdana | GeorgiaFont Size: ← →Problem DescriptionGiven a specified total t and a list of n integers, find all distinct sums using numbers fr 阅读全文

posted @ 2011-08-11 20:20 more think, more gains 阅读(219) 评论(0) 推荐(0) 编辑

Accepted Necklace hdu 2660

摘要: Accepted NecklaceTime Limit: 2000/1000 MS (Java/Others)Memory Limit: 32768/32768 K (Java/Others)Total Submission(s): 1022Accepted Submission(s): 406Problem DescriptionI have N precious stones, and plan to use K of them to make a necklace for my mother, but she won't accept a necklace which is to 阅读全文

posted @ 2011-08-11 18:59 more think, more gains 阅读(263) 评论(0) 推荐(0) 编辑

递归 DFS

摘要: #include <stdio.h>#include <string.h>#include <stdlib.h>int sum = 0;char ch[3] = {'L', 'R','P'};void DFS(int x, int n, int t ){ int i; if (n == t) { sum += x; return ; } for (i = 0; i < 3; i++) if( ch[i] == 'L') DFS(2 * x , n + 1, t); else if ( ch 阅读全文

posted @ 2011-08-11 17:02 more think, more gains 阅读(208) 评论(0) 推荐(0) 编辑

上一页 1 ··· 35 36 37 38 39 40 41 42 43 ··· 99 下一页

导航