简单dp,有O(n)做法,这里O(n^2)水过 1 #include 2 #include 3 #include 4 #include 5 6 using namespace std; 7 8 #define OJ 9 10 #ifdef OJ11 #define fin cin12 #...
分类:
其他好文 时间:
2014-11-14 22:27:11
阅读次数:
263
Cow Bowling
http://poj.org/problem?id=3176
Time Limit: 1000MS
Memory Limit: 65536K
Description
The cows don't use actual bowling balls when they go bowling. They each ta...
分类:
其他好文 时间:
2014-11-14 17:50:52
阅读次数:
224
题目大意:让求长度为n的0 和 1 构成的串中不包含101子串的个数有多少。这个题当时想了好久,以为是一个规律题,一直在推规律,最后还是wa了,上网一看原来是dp问题, 不过确实递推式挺巧妙的。递推式dp[i] = 2 * dp[i - 1] - dp[i - 2] + dp[i - 3];现在就来...
分类:
其他好文 时间:
2014-11-14 15:32:38
阅读次数:
192
这道题也是简单dp里面的一种经典类型,递推式就是dp[i] = min(dp[i-150], dp[i-200], dp[i-350])代码如下: 1 #include 2 #include 3 using namespace std; 4 int dp[10010]; 5 int main() ....
分类:
其他好文 时间:
2014-11-14 15:29:02
阅读次数:
296
Machine
Time Limit: 2 Seconds Memory Limit: 65536 KB
In a typical assembly line, machines are connected one by one. The first machine's output product will be the second machine's raw mater...
分类:
系统相关 时间:
2014-11-12 16:30:03
阅读次数:
173
题目意思:
给出一个数字三角形,计算从头走到尾的数字之和的最大值。规定只能向下向右下走。
http://poj.org/problem?id=1163
题目分析:
简单DP,动态转化方程:dp[i][j]=max(dp[i+1][j],dp[i+1][j+1])+a[i][j].从下到上进行dp
AC代码:
#include
using namespace std;
i...
分类:
其他好文 时间:
2014-11-08 23:42:45
阅读次数:
329
有个坑点,就是转移的时候前面状态数量如果不同,后面即使从同一个点转移过来,也是不同的。#include#include#include#include#include#includeusing namespace std;typedef long long LL;const LL maxn = 11...
分类:
其他好文 时间:
2014-11-04 09:17:01
阅读次数:
196
链接:http://acm.hdu.edu.cn/showproblem.php?pid=1520题意:给出一个职场关系图,每一个人有自己的价值,而且每一个人仅仅有一个领导,我要邀请的人不能够是一个人和他的直系领导,问最多能邀请到多少价值的人。思路:入门题,就是把简单DP运用到了树这样的数据结构里,...
分类:
其他好文 时间:
2014-11-03 16:01:52
阅读次数:
205
/*H - 简单dp 例题扩展Time Limit:3000MS Memory Limit:65536KB 64bit IO Format:%I64d & %I64uSubmit StatusDescriptionA palindrome is a symmetrical strin...
分类:
其他好文 时间:
2014-10-31 20:33:20
阅读次数:
134