一道跟哈希没有任何关系的题目
就是一道LCS模版题
普通写法
//洛谷P2543
#include<bits/stdc++.h>
#include <map>
#include <set>
#include <ctime>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <vector>
#include <cstring>
#include <cstdlib>
#include <iostream>
#include<algorithm>
#include<cmath>
#include<stdlib.h>
using namespace std;
int dp[5000][5000];
int main()
{
string x,y;
cin>>x>>y;
int n=x.length();
int m=y.length();
for(int i=1;i<=n;i++)
{
for(int j=1;j<=m;j++)
{
if(x[i-1]==y[j-1])
dp[i][j]=dp[i-1][j-1]+1;
else
{
dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
}
}
}
cout<<dp[n][m]<< endl;
}
//洛谷P25