摘要:
题意:先给一个序列,求两个最长连续子序列的和,看公式就很容易理解题意。思路:最长连续子序列的状态转移方程f[i]=max(f[i-1]+w[i],w[i])解决这道题的关键点在于要先正序处理一遍,然后再逆序处理一遍。然后枚举这个序列的分割点。这样时间复杂度为O(n);#include<iostream>
#define max(a,b) (a>b?a:b)
using namespace std;
const int N=50005;
int n;
int mat[N];
int remat[N];
int in[N];
void dp()
{ for(int i=1;i&l 阅读全文
posted @ 2011-11-12 19:34
不是我干的
阅读(180)
评论(0)
推荐(0)
摘要:
入门题。#include<iostream>
#include<string>
#define max(a,b) (a>b?a:b)
using namespace std;
char s1[500],s2[500];
int n1,n2;
int mat[2][500];
int main()
{ while(scanf("%s%s",s1+1,s2+1)!=EOF) { memset(mat,0,sizeof(mat)); n1=strlen(s1+1); n2=strlen(s2+1); for(int i=1;i<=n1;i++) 阅读全文
posted @ 2011-11-12 16:31
不是我干的
阅读(116)
评论(0)
推荐(0)
浙公网安备 33010602011771号