andre_joy

导航

上一页 1 2 3 4 5 6 7 8 9 ··· 15 下一页

2012年9月17日

hdu 4293

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=4293题意:一行人行走,分成很多组,每个人要说出他前面和后面分别有多少个人,他自己团队的人可以忽略,问最多有多少人说真话了。mark:学习了大牛的思路,真是没话说。。想不到……大牛的思路是dp[i][j]代表前i个人并且i+1到j个人是一个团队的时候,最多有多少人说真话。 http://blog.csdn.net/taozifish/article/details/7985044 我在研究了他的代码之后,发现代码可以优化,优化之后顿时有一种豁然开朗的感觉,我知道为什么会这样想了。 dp[i]... 阅读全文

posted @ 2012-09-17 20:34 andre_joy 阅读(152) 评论(0) 推荐(0) 编辑

2012年9月16日

hdu 4291

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=4291题意:g(n) = 3*g(n-1)+g(n-2),求g(g(g(n)))。mark:本地打表找循环节。。。囧,第一次做这种题。找到后直接快速幂。代码:#include <cstdio>#include <cstring>#include <cstdlib>#include <cmath>#include <iostream>#include <algorithm>#include <map>#define LL 阅读全文

posted @ 2012-09-16 22:03 andre_joy 阅读(263) 评论(0) 推荐(0) 编辑

2012年9月12日

hdu 4284

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=4284题意:给出一些城市,从1出发,旅游一圈回到1,由于花费可能不够,所以选择一些城市打工,打工之前需要花费d买一个证,工资为c。选中的城市必须去工作一次,而且只能工作一次,问能不能完成旅行mark:先用floyd预处理,记住一定要把断点放在最外层循环!!!状态压缩dp。代码:#include <cstdio>#include <cstring>#include <cstdlib>#include <cmath>#include <iostream& 阅读全文

posted @ 2012-09-12 16:44 andre_joy 阅读(93) 评论(0) 推荐(0) 编辑

2012年9月11日

hdu 4283

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=4283题意:一些人排好序,然后先进黑屋子,然后再出来去舞台,黑屋子是相当于一个栈,先进后出,每个人去舞台都有一个不开心值,求不开心值最小的做法。mark:记忆化搜索。代码:#include <cstdio>#include <cstring>#include <cstdlib>int min(int a, int b) {return a < b ? a : b;}const int INF = 10000000;int d[110], sum[110][110 阅读全文

posted @ 2012-09-11 21:56 andre_joy 阅读(327) 评论(0) 推荐(0) 编辑

hdu 4281

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=4281题意:有n个任务等待完成,每个任务有位置,所需时间,每个人最多m分钟。 第一问是求这些任务最少几个人完成;第二问是给无数个人,问最少需要多少分钟完成所有任务,并且每个人上限还是m。mark:第一问可以状态dp,可以01背包记录一下,然后回溯。 第二问参见了大牛的做法,先状态dp,然后暴力搜索一下。 今天才了解到状态压缩dp可以有两种方式写,第一种是从前往后扫一遍,每次转换这个状态能够到达的状态(因为状态肯定是由值小的到值大的) 第二种是用队... 阅读全文

posted @ 2012-09-11 11:49 andre_joy 阅读(235) 评论(0) 推荐(0) 编辑

2012年8月29日

UVaOJ 10106

摘要: 地址:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=1047题意:大数乘法代码:#include <stdio.h>#include <string.h>#include <stdlib.h>char a[260],b[260];int x[260], y[260], mut[610];int main(){ while(~scanf("%s%s", a, b)) { me 阅读全文

posted @ 2012-08-29 15:55 andre_joy 阅读(152) 评论(0) 推荐(0) 编辑

UVaOJ 424

摘要: 地址:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&category=97&page=show_problem&problem=365题意:求大数a+b代码:#include <stdio.h>#include <string.h>#include <stdlib.h>char a[200], sum[200];int main(){ int le,i,j,k; memset(sum, '0', sizeof(sum)) 阅读全文

posted @ 2012-08-29 15:31 andre_joy 阅读(176) 评论(0) 推荐(0) 编辑

hdu 1010

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1010题意:迷宫,是否能恰好t步走到终点。mark:奇偶剪枝法!!!这篇博客写的不错http://www.cppblog.com/Geek/archive/2010/04/26/113615.html代码:#include <stdio.h>#include <string.h>#include <stdlib.h>int n,m,t,sum,flag;char a[10][10];int s1,s2,d1,d2;int tab[4][2] = {1, 0, -1, 阅读全文

posted @ 2012-08-29 14:31 andre_joy 阅读(103) 评论(0) 推荐(0) 编辑

hdu 1059

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1059题意:有价值为1,2,……,6的大理石各若干个,求是否能平分给两个人。mark:看别人说多重背包,一直不知道在说什么。后来终于懂了,把总价值平分,往背包里放东西,如果最后恰好等于总价值的一半,那么就可以放进去。 这个代码就当模版用了。。代码:#include <stdio.h>#include <string.h>#include <stdlib.h>int a[7], vmax;int dp[120010];int max(int a, int b) {ret 阅读全文

posted @ 2012-08-29 10:58 andre_joy 阅读(156) 评论(0) 推荐(0) 编辑

2012年8月20日

hdu 1080

摘要: 地址:http://acm.hdu.edu.cn/showproblem.php?pid=1080题意:匹配两个人相似度。A,G,C,T,每两个都会有一个对应的值,给出两串基因,长度可以不一样,可以在基因中间加_使两串长度一样,然后有一个对应值,求最大对应值。mark:LCS的升级版。dp[i][j] = max(dp[i-1][j]+tab[s[0][i-1]][4], dp[i][j-1]+tab[s[1][j-1]][4], dp[i-1][j-1]+tab[s[0][i-1]][s[1][j-1]]);代码:#include <stdio.h>#include <st 阅读全文

posted @ 2012-08-20 21:11 andre_joy 阅读(216) 评论(0) 推荐(0) 编辑

上一页 1 2 3 4 5 6 7 8 9 ··· 15 下一页