#include #include #include using namespace std; list sol; #define MAX(A, B) ((A)>(B)?(A):(B)) int opt[100][100] ; inline int subMax(int x, int y) { int tmax=0; for(int i=x; i tmax) tmax = opt[x][i]+opt[i+1][y]; return tmax; } int main() { string s; cin >> s; while(s!="end") { //cout << "NEW STRING ... " << s << endl; for(int i=0; i<100; i++) for(int j=0; j<100; j++) opt[i][j]=0; for(unsigned i=1; i<=s.length(); i++) for(unsigned j=0; jopt[j][j+i]) opt[j][j+i]=k; } } //cout << j << " " << j+i << " " << opt[j][j+i] << endl; } cout << opt[0][s.length()-1] << endl; cin >> s; } }