摘要:
比较赤裸的KMP,将主串延长一倍即可达到旋转匹配的效果。/* * hdu2203/win.cpp * Created on: 2012-7-28 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <algorithm>#include <iostream>#include <queue>using namespace std;const int MAX_PAR_LEN = 阅读全文
摘要:
这题看完感觉就是DP,然后我当然就用记忆化搜索打了,打着打着,觉得想法不一定对,但打完交了一遍,MLE,改小数组再交,就过了,但其实还没有完全理解透。算是混过的。相当于DP的方法,dp[i][j]表示前i根筷子组成j组的最小值。我觉得关键的问题在于要先反着排序,然后如果筷子数刚好是人数的3倍时,最小的两根必定会在同一组中,且是一组中的较小的两根。/* * hdu1500/win.cpp * Created on: 2012-7-27 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstr 阅读全文
摘要:
这题几年前就看过,一直没看懂啊。。。今天翻解题报告,才知道就是求n/1、n/2、n/3、...、n/(n-1)、n/n的和,并且以分数的形式表示,还算简单。/* * hdu1099/win.cpp * Created on: 2012-7-27 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <ctime>#include <iostream>#include <algorit 阅读全文
摘要:
就是找一个区间,其被覆盖次数最多,输出即可。。/* * hdu1050/win.cpp * Created on: 2012-7-27 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <ctime>#include <iostream>#include <algorithm>#include <queue>#include <set>#includ 阅读全文
摘要:
水题,直接贴代码/* * hdu1009/win.cpp * Created on: 2012-7-27 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <ctime>#include <iostream>#include <algorithm>#include <queue>#include <set>#include <map>#i 阅读全文
摘要:
维护一个单调栈,如果当前的高度小于栈顶的,则弹栈,直到当前的高度大于栈顶,将当前的入栈。要注意高度为0的情况,开始忘考虑了,WA了一次。/* * hdu1008/win.cpp * Created on: 2012-7-24 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <ctime>#include <iostream>#include <algorithm>#inc 阅读全文
摘要:
一看就可以用母函数做,不过好久没练DP了,所以还是用DP做了。用dp[i][j]表示前i种石头排出j个出来的种数,当考虑第i种石头石,枚举其使用的个数即可。WA了好几次,是整数相乘精度的问题,使用long long就过了。/* * hdu1004/win.cpp * Created on: 2012-7-24 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <ctime>#include < 阅读全文
摘要:
罗马数字转阿拉伯数字,还只限12以内的。。。还有更水的赛题么。。/* * hdu1012/win.cpp * Created on: 2012-7-24 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <ctime>#include <iostream>#include <algorithm>#include <queue>#include <set&g 阅读全文
摘要:
挺水的,边长肯定是最大的箱子的边长加上次大的箱子的边长/* * hdu1003/win.cpp * Created on: 2012-7-24 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <ctime>#include <iostream>#include <algorithm>#include <queue>#include <set>#in 阅读全文
摘要:
水题,不说什么了。/* * hdu1001/win.cpp * Created on: 2012-7-24 * Author : ben */#include <cstdio>#include <cstdlib>#include <cstring>#include <cmath>#include <ctime>#include <iostream>#include <algorithm>#include <queue>#include <set>#include <map># 阅读全文