| ||||||||||
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 |
哪位帮我看看....我用的是最大子段方法...老是runtime error#include "iostream" using namespace std; int main() { short f[5010][5010]; char a[5010],b[5010]; int i,j,N; cin>>N; for(i=1;i<=N;i++) { cin>>a[i]; b[N-i+1]=a[i]; } for(i=0;i<=N;i++) f[i][0]=0; for(j=0;j<=N;j++) f[0][j]=0; for(i=1;i<=N;i++) for(j=1;j<=N;j++) if(a[i]==b[j]) f[i][j]= f[i-1][j-1]+1; else if(f[i-1][j]>=f[i][j-1]) f[i][j]=f[i-1][j]; else f[i][j]=f[i][j-1]; cout<<N-f[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