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 |
为什么是WA?哪儿有错误,请大牛指点#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: |
All Rights Reserved 2003-2013 Ying Fuchen,Xu Pengcheng,Xie Di
Any problem, Please Contact Administrator