摘要: http://ac.jobdu.com/problem.php?id=1420其实就是0-1背包,要求两集合之差绝对值最小,不妨求“当背包容量为所有数之和一半时,能放入背包的总重量",求出这个来,结果就出来了动态分配的内存,因为有的数据比较大,怕超内存。还有,就是内存在使用之前一定要初始化,malloc是不会自动初始化的。 1 #include <stdio.h> 2 #include <stdlib.h> 3 #include <string.h> 4 int max(int a,int b) 5 { 6 return a>b?a:b; 7 阅读全文
posted @ 2012-03-18 20:24 linyvxiang 阅读(329) 评论(0) 推荐(0) 编辑
摘要: http://ac.jobdu.com/problem.php?id=1416 1 #include <stdio.h> 2 #include <algorithm> 3 #include <string.h> 4 using namespace std; 5 int n,m; 6 struct Monkey{ 7 char name[101]; 8 int stronger_level; 9 int food_to_eat;10 int need;11 }monkey[10005];12 bool cmp(struct Monkey a,struct Mo 阅读全文
posted @ 2012-03-18 11:06 linyvxiang 阅读(246) 评论(0) 推荐(0) 编辑
摘要: http://ac.jobdu.com/problem.php?id=1419 1 #include <stdio.h> 2 #include <string.h> 3 #include <algorithm> 4 using namespace std; 5 struct Record{ 6 char orig_name[201]; 7 char trans_name[201]; 8 }record[201]; 9 void trans(int n)10 {11 int i;12 for(i=0;i<=strlen((record[n].orig_n 阅读全文
posted @ 2012-03-18 11:05 linyvxiang 阅读(243) 评论(0) 推荐(0) 编辑