您的位置:首页 > 其它

POJ 3267 The Cow Lexicon

2012-12-03 22:27 405 查看
这道题我先读错了题,然后又是推错了方程。。。额。。智商捉急啊。。。。

#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;
char str[320],dic[620][40];
int w,l;
int main()
{
int i,j,t1,t2;
int d[320];
scanf("%d%d",&w,&l);
getchar();
scanf("%s",str);
for (i=0; i<w; i++)
scanf("%s",dic[i]);

memset(d,0,sizeof(d));
d[0]=0;
for (i=1; i<=l; i++)
{
d[i]=d[i-1]+1;
for (j=0; j<w; j++)
{
t1=strlen(dic[j])-1;
t2=i-1;
while (t2 >= 0 && t1 >= 0)
{
if (dic[j][t1] == str[t2])
{
t1--;
}
t2--;
}
if (t1 == -1)
{
d[i]=d[i]<d[t2+1]+i-t2-1-strlen(dic[j])?d[i]:d[t2+1]+i-t2-1-strlen(dic[j]);
}
}
}
printf("%d\n",d[l]);
}
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: