本文出自:http://blog.csdn.net/svitter
题意分析:
Given m sequences, each contains n non-negative integer. Now we may select one number from each sequence to form a sequence with m integers. It's clear
...
分类:
其他好文 时间:
2014-08-03 12:54:15
阅读次数:
912
每个dp 没个30来分钟 tm的就写不出什么状态转移方程 还是太弱了啊=-= touch me其实用滚动数组 就是看你上一个状态转移到当前状态 与 i 前面多少个有关系 因为这里需要用到 i - 2 i - 1那么其实只要用 i % 3就可以了像上一题 我们只涉及到 i + 1那么只...
分类:
其他好文 时间:
2014-08-02 12:20:33
阅读次数:
256
Robot
Problem Description
Michael has a telecontrol robot. One day he put the robot on a loop with n cells. The cells are numbered from 1 to n clockwise.
At first the robot is in ce...
分类:
其他好文 时间:
2014-08-01 19:55:22
阅读次数:
319
HDU 4906 Our happy ending
题目链接
题意:给定n个数字,每个数字可以是0-l,要选其中一些数字,然后使得和为k,问方案
思路:状压dp,滚动数组,状态表示第i个数字,能组成的数字状态为s的状态,然后每次一个数字,循环枚举它要选取1 - min(l,k)的多少,然后进行状态转移
代码:
#include
#include
typedef ...
分类:
移动开发 时间:
2014-08-01 02:29:11
阅读次数:
392
Description
On Saint Valentine's Day, Alex imagined to present a special pendant to his girl friend made by K kind of pearls. The pendant is actually a string of pearls, and its length is defined a...
分类:
其他好文 时间:
2014-07-30 17:30:44
阅读次数:
349
给一字符串,问最少加几个字符可以让它成为回文串
比如 Ab3bd 最少需要两个字符可以成为回文串 dAb3bAd
思路:
动态规划 DP[i][j] 意味着从 i 到 j 这段字符变为回文串最少要几个字符,枚举子串长。
if str[i] == str[j]:
DP[i][j] = DP[i + 1][j - 1]
else:
DP[i][j] = min( DP[i +...
分类:
其他好文 时间:
2014-07-19 02:35:45
阅读次数:
198
01背包,DP简答题就行,要用滚动数组,不然内存要爆。for循环的方向很重要,虽然是简单题,但对理解DP帮助很大,听队长说要把每一个状态写出来,我试着写了一下,果然更容易理解了。 1 #include 2 #include 3 #define doumax(a,b) (a>b?a:b) 4 cons...
分类:
其他好文 时间:
2014-07-18 09:23:32
阅读次数:
181
区间动规主要有两种方法:
一、是先想出递归式,然后将之转化为滚动数组。
二、或者从小区间贪到大区间。
POJ 1159 点击打开链接
AC代码如下:
#include
#include
#include
using namespace std;
char a[5005];
short dp[5005][5005];
int min(int a,int b)
{
retu...
分类:
其他好文 时间:
2014-07-14 14:01:43
阅读次数:
187
也是多重背包可行性问题。时间复杂度为 O(VN); V=背包容量,N=物品数量。
题意是说给你N个物品,每个物品有不同的价值与数量。分给两个院。
问你怎么分配才让能让价值尽量相等。
跟我上一篇解题报告是一种类型。以价值为费用,总价值的一半为背包容量。
不过物品有点多,直接开数组可能会超内存。我就用了滚动数组。
需要注意的是 you should guarant...
分类:
其他好文 时间:
2014-07-13 15:45:40
阅读次数:
208