摘要: 链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&problem=2829View Code 1 #include <iostream> 2 #include <cstdio> 3 #include <string> 4 #include <cstring> 5 #include <cmath> 6 #include <vector> 7 #include <alg 阅读全文
posted @ 2013-01-09 22:02 淡墨æ末央 阅读(118) 评论(0) 推荐(0) 编辑
摘要: 链接:http://uva.onlinejudge.org/index.php?option=com_onlinejudge&Itemid=8&page=show_problem&category=&problem=2267&mosmsg=Submission+received+with+ID+11118596View Code 1 #include <iostream> 2 #include <cstdio> 3 #include <string> 4 #include <cstring> 5 #incl 阅读全文
posted @ 2013-01-09 21:09 淡墨æ末央 阅读(178) 评论(0) 推荐(0) 编辑
摘要: 链接:http://poj.org/problem?id=3612题意:有N根柱子, 高度确定, 现在要使它们连接起来,划分为相邻的柱子的高度差 h *C, 还可以加高度, 花费为所加高度 x 的平方;求最小花费;思路:朴素的想法: 用dp[i][j] 代表第 i 根柱子高度为 j 时的最小花费, 那么 dp[i][j] = dp[i-1][k] + abs( j-k ) * C + (j-a[i])^2;复杂度为 10^5*10^2*10^2 = 10^9 TLE 无压力 ;再来看上面的式子, 去绝对值得到 dp[i][j]=dp[i][k]+(j-k)*C+j-a[i]^2 = dp[i] 阅读全文
posted @ 2013-01-09 15:37 淡墨æ末央 阅读(134) 评论(0) 推荐(0) 编辑