#include #include using namespace std;int dp[1005], w[105],v[105],T,M;int max(int x,int y) { return x>y?x:y; }void f( ){ int i,j; for (i...
分类:
其他好文 时间:
2014-08-12 21:48:14
阅读次数:
203
zoj 1733#include #include #define N 1005using namespace std ;char s1[N],s2[N];int dp[N][N];int max(int a,int b){ return a>b ? a : b ; }void f(int...
分类:
其他好文 时间:
2014-08-12 21:18:44
阅读次数:
216
Description
YH gave Qz an odd matrix consists of one or zero. He asked Qz to find a square that has the largest area. The problem is not so easy, that means the square you find must not contai...
分类:
其他好文 时间:
2014-08-12 19:11:04
阅读次数:
208
#include #include#includeusing namespace std;char a[10002];int b[10002];int n,ans;int dp(int x){ int i,j,max; b[0]=1; for(i=1;i>n;for(i=1;i#include#.....
分类:
其他好文 时间:
2014-08-12 18:57:04
阅读次数:
183
#include #define MAX 50+1int fib(int n){ int i,a[MAX]; a[1]=a[2]=1; for (i=3; i<=n; i++) a[i]=a[i-1]+a[i-2]; return a[n];}void main( )...
分类:
其他好文 时间:
2014-08-12 18:46:14
阅读次数:
205
HDU 4026 Unlock the Cell Phone(动态规划)
题目大意:
给一张图,问你解锁屏幕的方案数,0 表示按键,当被触摸过可以跳过,1表示不能被跳过,2表示可以被跳过。
问你按键的方法数?
解题思路:
用“ 0 1 ” 的二进制 表示0号按键的状态。...
分类:
其他好文 时间:
2014-08-12 17:14:54
阅读次数:
255
HDU 4028 The time of a day(动态规划)
题目大意:
有n组测试数据,接下来n和m,n表示n个指针1~n,分别是 k 下回到起点,问你从n个选出任意多个指针,同时停在起点算1天,1天的时间超过m的方案有多少种?
解题思路:
动态规划,状态较分散,所以用Map离散化。...
分类:
其他好文 时间:
2014-08-12 17:11:44
阅读次数:
208
作为新人,之前对C,C++了解的比较少,关于算法方面更是一窍不通,但最近却痴迷上了算法,哪怕是前辈们不屑一顾的东东,我弄明白了后都会欣喜若狂!今天将遇到的问题和java实现贴出来和同为新人的博友分享,老鸟可以可以直接关网页了。定义: 子序列:一个给定序列的子序列是再该序列中删去若干元素后得到的序列....
分类:
其他好文 时间:
2014-08-12 12:39:14
阅读次数:
199
典型的记忆化递归问题。
这类问题的记忆主要是利用数组记忆,那么已经计算过的值就可以直接返回,不需要进一步递归了。
注意:下标越界,递归顺序不能错,及时判断是否已经计算过值了,不要多递归。
或者直接使用动态规划法填好表也是可以的。
#include
#include
const int MAX_N = 21;
int W[MAX_N][MAX_N][MAX_N];
int g...
分类:
其他好文 时间:
2014-08-12 10:26:23
阅读次数:
232
题意 所有只能被2,3,5,7这4个素数整除的数称为Humble Number 输入n 输出第n个Humble Number
1是第一个humble number 对于一个Humble Number a 有2*a,3*a,5*a,7*a都是Humble Number 可以以1为基数 依次展开即可得到一定范围内的Humble Number 用i,j,k,l分别记录 2,3,5,7分别乘到了第几个Humble Number 当前在计算第cnt个Humble Number 那么有 hum[c...
分类:
其他好文 时间:
2014-08-12 10:20:23
阅读次数:
202