摘要: 题目链接很不错的一个DP,结果让我糟蹋了。。想了半天把状态方程想出来,结果编程的时候,把一个1写成i了,在SCF和QC的帮助下查到了。。。真悲剧啊20+的提交。。。题意:老板雇人有,招人费,工人工资,开除人的费用。给出第几个月需要几个人。问最少的花费。二维DP。i代表月份,j代表在这个月的人数。所以这个月的情况跟上个月有关系,状态转移方程o[i][j] = min (o[i-1][k] +新的花费);按说1打成了i,应该是很大的错误,怎么过的数据啊。。。。 1 #include <stdio.h> 2 #include <string.h> 3 #define N 10 阅读全文
posted @ 2012-07-25 21:02 Naix_x 阅读(220) 评论(0) 推荐(0) 编辑
摘要: 题目链接题目直接说明题意了,求最长上升的公共子序。开一个标记数组,标记上一个匹配的数字就行。这个题坑爹的是输出格式,题目中根本没有说明,不过,猜猜就知道是每个样例之间有空行,还果真是。。。PS:这样是瞎搞过的。。。。杭电数据水了。。。2012.8.13PS:这份代码是正解,这个坑过了好久了,才来添。。。其实就是把dp[i][j][k],然后多一维记录上升长度为k,最小的数是多少。。。然后+各种优化,时间复杂度降低到O(n^2),然后空间复杂度也降了很多。。。2012.11.6 1 #include <cstdio> 2 #include <cstring> 3 usin 阅读全文
posted @ 2012-07-25 16:27 Naix_x 阅读(162) 评论(5) 推荐(0) 编辑
摘要: 题目链接和以前HDU1081很类似。1081有两种做法,一种是直接压缩成一维,一种是利用矩形内部加减。这个题,只能用后者吧,反正我用的后边一种方法。 1 #include <stdio.h> 2 #include <string.h> 3 __int64 p[1000][1000],o[1000][1000],sum[1000][1000]; 4 int main() 5 { 6 int i,j,m,n,t,x,y; 7 __int64 max; 8 scanf("%d",&t); 9 while(t--)10 {11 memset(p,.. 阅读全文
posted @ 2012-07-25 16:06 Naix_x 阅读(164) 评论(0) 推荐(0) 编辑
摘要: 题目链接map建哈希,题目中NC不知道搞神马的。。。 1 #include <iostream> 2 #include <cstdio> 3 #include <cstring> 4 #include <vector> 5 #include <map> 6 #include <queue> 7 #define N 16000001 8 using namespace std; 9 map <string,bool> p;10 char o[N],k[N];11 int main()12 {13 int t,i, 阅读全文
posted @ 2012-07-25 15:32 Naix_x 阅读(141) 评论(0) 推荐(0) 编辑
摘要: 题目链接当看懂这个题意的时候,就没啥难度了,百练上有个中文版的数据一模一样。。。普通O(n^2)DP。 1 #include <stdio.h> 2 #include <string.h> 3 #include <stdlib.h> 4 int o[2000]; 5 struct node 6 { 7 int x,y; 8 int h; 9 }p[2000];10 int cmp(const void *a,const void *b)11 {12 return (*(struct node *)a).x >(*(struct node *)b).x 阅读全文
posted @ 2012-07-25 14:52 Naix_x 阅读(140) 评论(0) 推荐(0) 编辑
摘要: 今天讲的是高精度加法减法。整理一下这部分,当模版了。。高精度加法,无小数部分。百炼 2981大整数加法算是精简了一点。 1 #include <stdio.h> 2 #include <string.h> 3 int p1[300],p2[300]; 4 int main() 5 { 6 char str1[201],str2[201]; 7 int i,len1,len2,max; 8 scanf("%s%s",str1,str2); 9 len1 = strlen(str1);10 len2 = strlen(str2);11 for(i =.. 阅读全文
posted @ 2012-07-25 10:49 Naix_x 阅读(673) 评论(3) 推荐(0) 编辑