2013年6月11日

poj2533 - Longest Ordered Subsequence(简单动规)

摘要: 状态:d[i]表示a[1.....i]的最长上升子序列状态转移:d[i] = max{d[j]+1|a[i]>a[j]}代码如下:#include #include #define N 1005 int n, a[N], d[N]; int main () { int max; while(~scanf("%d",&n)) { for(int i = 1; i a[j]&&ans #include #define N 1005 int n, a[N], c[N], dp[N]; int search(int l, int r, int x) { 阅读全文
posted @ 2013-06-11 21:44 Primo... 阅读(133) 评论(0) 推荐(0)

uva10069 - Distinct Subsequences(动规,大数)

摘要: 卡了我一天的题我还能说是水题吗。。。。开始的思路【半递推半搜索】虽然是不成熟的动规,但是我觉得至少还能过。看了人家比较成熟的思路却没有过。但最后还是用成熟的动规思路过的。代码挫在了写大数的地方。少了个等号,,,,状态:d[i][j]表示子串的前i-1个字符在母串前j-1个位置中出现的次数状态转移:(sub[i-1]==s[j-1])d[i][j] = d[i][j-1];(sub[i-1]!=s[j-1]) d[i][j] = d[i][j-1]+d[i-1][j-1];代码如下:#include #include #define M 10005 #define N 105 char s[.. 阅读全文
posted @ 2013-06-11 20:12 Primo... 阅读(126) 评论(0) 推荐(0)