| ||||||||||
Online Judge | Problem Set | Authors | Online Contests | User | ||||||
---|---|---|---|---|---|---|---|---|---|---|
Web Board Home Page F.A.Qs Statistical Charts | Current Contest Past Contests Scheduled Contests Award Contest |
加1是不是应该在下面加啊?没仔细看的说。。In Reply To:Why is this prog is wrong?? Posted by:ejkim7199 at 2006-07-09 13:41:47 > #include<iostream> > //#include<fstream> > #define MAX 5002 > using namespace std; > > int n,i,j,k; > char pal[MAX],m[MAX][MAX]; > > int main() > { > //ifstream cin("input.txt"); > //ofstream cout("output.txt"); > while(cin >> n) { > cin >> pal+1; > for(i = 1;i <= n;i++) { > for(j = n,k=1;j > 0;j--,k++) { > if(pal[i] == pal[j]) > m[i][k] = m[i-1][k-1]+1; > else if(m[i-1][k] > m[i][k-1]) > m[i][k] = m[i-1][k]; > else > m[i][k] = m[i][k-1]; > } > } > cout << n-(int)m[n][n] << endl; > } > return 0; > } Followed by: Post your reply here: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator