上一页 1 2 3 4 5 6 7 8 9 10 ··· 27 下一页
摘要: 赤裸裸的DFA,直接上模板了,可以交上去居然WA。仔细调了调,发现是原来自己写的模板有问题。之前写DFA模板的时候没有考虑到模式串会有重复并且还需要都统计的情况。大概改了改,能过这题了,但是代码改得挺乱,改天再整理整理吧。/* * hdu2222/win.cpp * Created on: 2013-1-6 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <ctime>#include < 阅读全文
posted @ 2013-01-06 19:32 moonbay 阅读(196) 评论(0) 推荐(0) 编辑
摘要: 好恶心的题目,题面那么长,害我折腾了几个小时。。。刚开始是在杭电做的这题,打完代码以后交不过,不得已查解题报告,才发现poj上也有这题。看了别人的解题报告之后才发现自己理解错了。于是推倒重来,重新写,可还是不过。问了问金牛,才发现居然还是理解错了题目,晕死啊。。。。最后根据那组数据调了一会儿,就过了。我的做法跟网上别人的做法一样,用的最大流。建图的时候,加一个源点一个汇点,源点连插座,流量为1,插座连电器,流量为1,电器连汇点,流量为1,然后如果插座A能通过适配器转换成插座B,就连A到B,流量无穷大。最大流就是最多能插上的电器数了。/* * hdu1526/win.cpp * Created 阅读全文
posted @ 2013-01-06 14:26 moonbay 阅读(132) 评论(0) 推荐(0) 编辑
摘要: 一个多月没刷题了,找了道水题玩玩。。。做法很简单。最后的结果一定是在N+1到2N之间的,因为最好的情况就是所有的绳子一样长;最坏的情况就是全都不一样长(此时把最小的那根平均切,其余的切出那个长度即可)。所以,最优解一定是有一种长度的绳子被均切,枚举这个即可。/* * hdu4476/win.cpp * Created on: 2013-1-3 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <ctim 阅读全文
posted @ 2013-01-03 22:38 moonbay 阅读(184) 评论(0) 推荐(0) 编辑
摘要: 还是比较简单的,广搜就行,不过我一开始以为用深搜也可以,还打了一部分代码,后来才想到是会超时的,因为题目中没有给出T的范围。/* * hdu2102/win.cpp * Created on: 2012-11-28 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <ctime>#include <iostream>#include <algorithm>#include 阅读全文
posted @ 2012-11-28 19:05 moonbay 阅读(144) 评论(0) 推荐(0) 编辑
摘要: 简单的三维空间求最短路,用广搜就可以了。/* * hdu1240/win.cpp * Created on: 2012-11-18 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <ctime>#include <iostream>#include <algorithm>#include <queue>#include <set>#include 阅读全文
posted @ 2012-11-18 12:09 moonbay 阅读(162) 评论(0) 推荐(0) 编辑
摘要: 最小生成树Prim算法的简单变形,Prim算法就是贪心的思想,从任一点开始,依次选择离已知点最近的点扩展,那么这题只要初始的时候把给出的两点加到已知点中即可。/* * hdu4463/win.cpp * Created on: 2012-11-17 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <ctime>#include <iostream>#include <algor 阅读全文
posted @ 2012-11-17 20:00 moonbay 阅读(308) 评论(0) 推荐(0) 编辑
摘要: 挺水的动态规划,只要依次枚举子树的个数即可。/* * hdu4472/win.cpp * Created on: 2012-11-17 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <ctime>#include <iostream>#include <algorithm>#include <queue>#include <set>#includ 阅读全文
posted @ 2012-11-17 18:38 moonbay 阅读(725) 评论(0) 推荐(1) 编辑
摘要: 这题的结果[f(1)+f(2)+...+f(n)]其实就等价于x*y*z<=n的解的个数,然后的方法几乎就是暴力枚举了。现场比赛的时候没想到这一点,太杯具了,浪费了两个小时的思考时间。其实我们的做法应该是可行的,因为f(n)具有积性性质,也就是若gcd(n, m)=1,则f(n*m)=f(n)*f(m)。而当p为质数时,f(p^k)=(k+1)*(k+2)/2,这样就能把f(n)数列的前n项和化成一堆多项式的加和。然后用合并同类项的思想,用容斥原理搞,可是代码量太大了,没打出来。。。今天赛题被挂到HDOJ上以后用上面说的枚举方法打了一下,交上去居然WA,调了半天也没发现错误,最后才怀疑是 阅读全文
posted @ 2012-11-12 16:53 moonbay 阅读(358) 评论(0) 推荐(0) 编辑
摘要: 这题公式不难推,就是控制精度的问题。因为公式是一些项求和,这里每一项都是接近于1的数,但是每一项里包含一个组合数和一个p^n,如果每次直接把p^n乘进去就会使数字太小,如果一直留到最后乘,可能中间就溢出了。解决的办法就是根据中间变量的大小动态地乘p^k,防止溢出,也防止数字太小丢精度离比赛结束已经有一段时间了,今天再来看这题,打算把它A掉,结果查了一下解题报告,发现这题其实有不需要控制精度的方法!!!唉,当时太SB了,这种方法居然都没想到,花了一两个小时去控制精度。其实只要在运算过程中全部取对数就可以了。。。。啊啊啊。。。/* * hdu4465/win.cpp * Created on: 2 阅读全文
posted @ 2012-11-12 16:42 moonbay 阅读(234) 评论(0) 推荐(0) 编辑
摘要: 对于现场赛出题出到这么水表示无语。。。。/* * hdu4464/win.cpp * Created on: 2012-11-17 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <ctime>#include <iostream>#include <algorithm>#include <queue>#include <set>#include 阅读全文
posted @ 2012-11-12 16:35 moonbay 阅读(796) 评论(0) 推荐(0) 编辑
上一页 1 2 3 4 5 6 7 8 9 10 ··· 27 下一页