//  136ms 过大的
1
int f[100][11000]; 2 class Solution { 3 public: 4 int numDistinct(string S, string T) { 5 // Start typing your C/C++ solution below 6 // DO NOT write int main() function 7 memset(f,0,100*11000); 8 9 int i,j; 10 const char *s=S.c_str(); 11 const char *t=T.c_str(); 12 for(i=0;i<11000;i++) 13 { 14 f[0][i]=1; 15 } 16 17 for(i=0;t[i];i++) 18 { 19 for(j=0;s[j];j++) 20 { 21 if(t[i]==s[j]) 22 { 23 f[i+1][j+1]=f[i+1][j]+f[i][j]; 24 } 25 else 26 { 27 f[i+1][j+1]=f[i+1][j]; 28 } 29 } 30 } 31 return f[i][j]; 32 } 33 };

 

posted on 2013-06-04 16:40  宇睿  阅读(124)  评论(0编辑  收藏  举报