原题地址:http://www.rqnoj.cn/problem/90解题思路:题目看起来不太像动态规划。。。我用一个数组f[i][j]来表示在数组第i个元素的后面第一次出现j的位置,为-1则是没出现过。然后每次查找最大的位置即可。如题目例子中:f
1 3 5 2 4 1 3 5 2 2 2 2.....
分类:
其他好文 时间:
2014-05-05 09:55:18
阅读次数:
448
代码:
#include
#include
#include
#include
using namespace std;
const int maxn=10003;
const int inf=0x7fffffff;
int num[maxn];
int n;
int main()
{
while(scanf("%d",&n)!=EOF&&n)...
分类:
其他好文 时间:
2014-05-04 12:39:16
阅读次数:
331
C代码实现如下: 1 #include 2 #include 3 4 int** DP(int
num, int Weight, int*w, int *v); 5 void output(int *c, int *w, int weight, int
**ptr, int num)...
分类:
其他好文 时间:
2014-05-04 10:09:07
阅读次数:
269
最长公共子序列经典问题,由于题的条件特殊,可转换成LIS问题,可在O(nlogn)内得到解决。根据刘汝佳大大的,加上自己的理解,不太理解的童鞋可以看一看(前提:已掌握LIS问题和LCS问题的解法)...
分类:
其他好文 时间:
2014-05-04 08:46:48
阅读次数:
339
本文出自:http://blog.csdn.net/svitter
括号匹配一:http://acm.nyist.net/JudgeOnline/problem.php?pid=2
括号匹配二:http://acm.nyist.net/JudgeOnline/problem.php?pid=15
之前被这个题目难住,现在看动态规划就顺便过来AC了它。结果发现当年被难住一点...
分类:
其他好文 时间:
2014-05-03 23:52:18
阅读次数:
408
题目:
Given a string S and a string T, count the number of distinct subsequences of T in S.
A subsequence of a string is a new string which is formed from the original string by deleting some (c...
分类:
其他好文 时间:
2014-05-03 21:48:19
阅读次数:
252
Tickets
Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 4 Accepted Submission(s) : 2
Font: Times New Roman | Verdana | Georgia
Font Size: ←...
分类:
其他好文 时间:
2014-05-03 21:16:19
阅读次数:
360
Super Jumping! Jumping! Jumping!
Time Limit : 2000/1000ms (Java/Other) Memory Limit : 65536/32768K (Java/Other)
Total Submission(s) : 6 Accepted Submission(s) : 5
Font: Times New Roman | Verdan...
分类:
其他好文 时间:
2014-05-03 16:47:07
阅读次数:
262