#include
<
iostream
>
using
namespace
std;
int
n;
short
f[
5001
][
5001
]
=
{
0
};
char
s[
5000
];
int
main()
{
scanf(
"
%d
"
,
&
n); getchar();
gets(s);
for
(
int
i
=
1
;i
<=
n;
++
i)
for
(
int
j
=
1
;j
<=
n;
++
j)
if
(s[i
-
1
]
!=
s[n
-
j]){
if
(f[i][j
-
1
]
>
f[i
-
1
][j])
f[i][j]
=
f[i][j
-
1
];
else
f[i][j]
=
f[i
-
1
][j];
}
else
f[i][j]
=
f[i
-
1
][j
-
1
]
+
1
;
printf(
"
%d\n
"
,n
-
f[n][n]);
return
0
;
}
posted on 2009-05-02 22:14
xfstart07 阅读(83)
评论(0) 编辑 收藏 引用 所属分类:
代码库