PKU 1458 Common Subsequence(最长公共子序列,dp,简单)

题目

同:ZJU 1733,HDU 1159

#include <stdio.h>
#include <string.h>
#include <algorithm>
using namespace std; int dp[][];
int main()
{
char a[], b[];
int la, lb;
while(scanf("%s%s", a, b) != EOF)
{
memset(dp, , sizeof(dp));
la = strlen(a), lb = strlen(b);
for(int i = ; i < la; i++)
{
for(int j = ; j < lb; j++)
{
if(a[i] == b[j])
{
dp[i+][j+] = dp[i][j] + ;
}
else
{
dp[i+][j+] = max(dp[i+][j], dp[i][j+]);
}
}
}
printf("%d\n", dp[la][lb]);
}
return ;
}
上一篇:SqlServer2012 数据库的同步之SQL JOB + 建立链接服务器


下一篇:[MySQL复制异常]'Cannot execute statement: impossible to write to binary log since statement is in row format and BINLOG_FORMAT = STATEMENT.'