将课本上所述方法实现即可,代码如下:
/* * Author: Bingo * Created Time: 2015/1/25 23:49:49 * File Name: uva11584.cpp */#include#include #include #include #include #include #include #include #include #include #include #include using namespace std;const int maxint = -1u>>1;const int maxlen=1050;int d[maxlen];int s[maxlen][maxlen];string st;int work(){ int len=st.size(); memset(s,0,sizeof(s)); for (int i=0;i =0&&q =0&&q =0&&q >T; //string st; while (T--){ cin>>st; work(); int len=st.size(); for (int i=0;i