思路: 简单的区间dp,从小区间到大区间,随便写. 还有一种是那啥,n-LCS...具体不说了,赶时间)))= =. #include <stdio.h> #include <string.h> #include <iostream> using namespace std; typedef long long LL; const int N=1e3+10; char s[N]; int dp[N][N]; int main() { int n; scanf("…
题目地址:http://www.51nod.com/onlineJudge/questionCode.html#!problemId=1021 经典区间dp,dp[i][j] 表示将从 i 到 j 堆石子合并最小代价,长度为 j-i+1,可看做之前已经合并的 i 到 k 和 k 到 j 两堆石子合并,代价是 i 到 j 的石子数量: #include<iostream> #include<cstring> #include<algorithm> using namesp…
Dima the hamster enjoys nibbling different things: cages, sticks, bad problemsetters and even trees! Recently he found a binary search tree and instinctively nibbled all of its edges, hence messing up the vertices. Dima knows that if Andrew, who has…