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

为什么是WA?哪儿有错误,请大牛指点

Posted by 791121 at 2010-05-25 12:29:17 on Problem 1159 and last updated at 2010-05-25 12:29:51
#include "stdio.h"
char a[5001],tmp[5001][5001];
int string(int i, int j)
{
	int m, n;
	if (i >= j){
		return 0;
	}
	if (tmp[i][j] > 0){
		return(tmp[i][j]);
	}
	if (a[i] == a[j]){
		tmp[i][j] = string(i+1,j-1);
		return(tmp[i][j]);
	}
	else {
		m = string(i,j-1);
		n = string(i+1,j);
		tmp[i][j] = (m>n?n:m) + 1;
		return(tmp[i][j]);
	}
}
void main()
{
    int n, i;
    scanf("%d\n",&n);
    for (i = 0; i < n; i++){
    	scanf("%c",&a[i]);
    }
    printf("%d\n",string(0,n-1));
}

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