HDU 3336 Count the string(乱搞)
2012-08-17 19:01
330 查看
题目链接
有点BFS的思想,不过还是感觉像是乱搞题。。
有点BFS的思想,不过还是感觉像是乱搞题。。
#include <stdio.h> #include <string.h> #include <stdlib.h> #define N 200001 #define M 10007 char str ; int p ; int main() { int i,j,t,n,start,end,ans; scanf("%d",&t); while(t--) { scanf("%d%*c",&n); gets(str); ans = n%M; start = 0; j = 0; for(i = 1;i <= n-1;i ++) { if(str[i] == str[0]) { p[j] = i; ans++; j ++; } } end = j-1; for(i = 1;i <= n-1;i ++) { j = 0; while(start <= end) { if(str[p[start]+1] == str[i]) { ans++; p[j] = p[start]+1; j ++; } start ++; } if(ans > M) ans = ans%M; if(j == 0) break; start = 0; end = j-1; } printf("%d\n",ans); } return 0; }
相关文章推荐
- Hdu 3336 Count the String(DP+KMP)(好题)
- hdu -- 3336 Count the string(KMP + dp)
- hdu 3336 (Count the string) next数组+dp
- HDU 3336 Count the string 后缀数组 或 (KMP + DP)
- HDU 3336 Count the string
- 【HDU 3336】Count the string(kmp)
- HDU 3336 Count the string (记忆化搜索)
- hdu 3336 Count the string(数据结构:KMP)
- hdu 3336 Count the string(KMP)
- hdu 3336 Count the string
- hdu 3336 Count the string
- HDU 3336 Count the string【EXKMP+逆向思考 OR KMP】
- HDU 3336 Count the string(KMP 理解)
- HDU 3336 Count the string(KMP)
- HDU 3336 Count the string KMP
- hdu 3336 Count the string KMP模式匹配 ★★★
- hdu 3336 Count the string
- Hdu 3336 Count the string(求给定字符串含前缀的数量)
- hdu 3336 Count the string(kmp应用)
- HDU 3336 Count the string(KMP)||记忆化搜索