随笔分类 - DP——区间
摘要:题目链接:http://lightoj.com/volume_showproblem.php?problem=1033#include #include #include #include #include #include #include using namespace std;const int maxe = 50000;const int maxn = 105;const int INF = 0x3f3f3f;int dp[maxn][maxn]; //dp[i][j]表示字符串中从i到j最少要添加的字母个数。int main(){ //freopen("E:\\acm\\.
阅读全文
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4293#include#include#include#includeusing namespace std;const int maxn = 506;int G[maxn][maxn];int dp[maxn]; //dp[i]表示前i个人,最大有多少个人没撒谎。int main(){ //freopen("E:\\acm\\input.txt","r",stdin); int N; while(cin>>N){ memset(G,0,sizeo
阅读全文
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4283#include#include#include#includeusing namespace std;const int maxn = 105;const int INF = 0x3f3f3f3f;int dp[maxn][maxn];//dp[i][j]表示只考虑编号为i到编号为j的人上场的最小不开心值;//枚举i第K(1=>T; for(int cas=1;cas>N; sum[0] = 0; for(int i=1;i=1;i--) ...
阅读全文
摘要:题目链接:http://lightoj.com/volume_showproblem.php?problem=1031#include#include#include#includeusing namespace std;const int maxn = 105;int dp[maxn][maxn]; //dp[i][j] 表示先手从i到j比后手多的分差。int sum[maxn],a[maxn];int N;int main(){ // freopen("E:\\acm\\input.txt","r",stdin); int T; cin>>
阅读全文
摘要:题目链接:http://acm.hdu.edu.cn/showproblem.php?pid=4632用点容斥原理转移状态,dp[i][j]=dp[i+1][j]+dp[i][j-1]-dp[i+1][j-1]当 s[i] == s[j], 要加上dp[i+1][j-1] + 1;我就是想的太复杂,而这个题有卡时间,无限TLE,悲剧啊!#include #include #include #include #include #include #include #define maxn 1050#define INF 0x3f3f3fusing namespace std;const int..
阅读全文