摘要:
很好的区间DP题。 需要注意第一种情况不管是否匹配,都要枚举k来更新答案,比如: “()()()”:dp[0][5]=dp[1][4]+2=4,枚举k,k=1时,dp[0][1]+dp[2][5]=6,最后取最大值6. 第一层d相当于“长度”的含义,第二层枚举i,j就可以用i+d表示,通过这种方式枚 阅读全文
posted @ 2022-06-17 21:18
YHXo
阅读(35)
评论(0)
推荐(0)
摘要:
禁止报的数的生成规则与埃式筛法类似,考虑用筛法预处理可以报出的数字列表和不可报出的数字,从而 O(1) 回答每一组询问。 用check函数判断数字中是否含有7,用nx[i]记录数字i的下一个合法数。 1 #include<bits/stdc++.h> 2 using namespace std; 3 阅读全文
posted @ 2022-06-17 20:58
YHXo
阅读(122)
评论(0)
推荐(0)
摘要:
dp[i][j]表示将字符串子区间[i,j]转化为回文字符串的最小成本。 1 #include<cstdio> 2 #include<algorithm> 3 #include<cstring> 4 #include<cmath> 5 #include<string> 6 #include<iost 阅读全文
posted @ 2022-06-17 19:40
YHXo
阅读(30)
评论(0)
推荐(0)
摘要:
dp[i][j]表示s1[1...i]和s2[1...j]的最长公共子序列。 1 #include <map> 2 #include <set> 3 #include <cmath> 4 #include <queue> 5 #include <cstdio> 6 #include <vector> 阅读全文
posted @ 2022-06-17 18:56
YHXo
阅读(30)
评论(0)
推荐(0)
摘要:
设dp[i]表示以i结尾的最长上升子序列的长度。 dp[i]=max(dp[i],dp[j]+1). 1 #include <map> 2 #include <set> 3 #include <cmath> 4 #include <queue> 5 #include <cstdio> 6 #incl 阅读全文
posted @ 2022-06-17 18:39
YHXo
阅读(29)
评论(0)
推荐(0)
摘要:
支付对应的是多重背包问题,找零对应完全背包问题。 难点在于找上限T+maxv*maxv,可以用鸽笼原理证明,实在想不到就开一个尽量大的数组。 1 #include <map> 2 #include <set> 3 #include <cmath> 4 #include <queue> 5 #incl 阅读全文
posted @ 2022-06-17 18:27
YHXo
阅读(46)
评论(0)
推荐(0)

浙公网安备 33010602011771号