趣题之家程序贴吧——LCS
|
LCS
|
基本信息:
提交人:SeaFrog 提交日期:4/28/2005 8:35:17 PM 点击数:1023 |
编辑 删除
|
|
程序简介:
AHOI2004第一题
|
程序内容:
#include<fstream.h>
#include<string.h>
ifstream fin("lcs.in");
ofstream fout("lcs.out");
const int maxlen=3000;
int ans[maxlen][maxlen];
char x[maxlen],y[maxlen];
int xx,yy;
int max(int a, int b) {
if (a > b) return a; else return b;
};
void init() {
fin >> x >> y;
};
void work() {
int i,j;
memset(ans, sizeof(ans), 0);
xx = strlen(x); yy = strlen(y);
for (i = 1; i <= xx; i ++)
for (j = 1; j <= yy; j ++) {
if (x[i-1] == y[j-1])
ans[i][j] = ans[i-1][j-1]+1;
else
ans[i][j] = max(ans[i-1][j],ans[i][j-1]);
};
};
void print() {
fout << ans[xx][yy] << endl;
};
int main() {
init();
work();
print();
return 0;
};
|
|
Microsoft OLE DB Provider for ODBC Drivers error '80004005'
[Microsoft][ODBC Microsoft Access Driver] Cannot update. Database or object is read-only.
/bbs/pascal_view.asp, line 345 |