Online JudgeProblem SetAuthorsOnline ContestsUser
Web Board
Home Page
F.A.Qs
Statistical Charts
Problems
Submit Problem
Online Status
Prob.ID:
Register
Update your info
Authors ranklist
Current Contest
Past Contests
Scheduled Contests
Award Contest
User ID:
Password:
  Register

加1是不是应该在下面加啊?没仔细看的说。。

Posted by yangguo981 at 2006-07-22 17:36:08 on Problem 1159
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:
User ID:
Password:
Title:

Content:

Home Page   Go Back  To top


All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator