8 char text
[maxm
],pat
[maxn
];
10 inline void get_next() {
11 int m
=strlen(pat
),k
=-1;
13 for (int q
=1; q
<m
; q
++) {
14 while (k
>-1 && pat
[k
+1]!=pat
[q
]) k
=next
[k
];
15 if (pat
[k
+1]==pat
[q
]) k
++;
21 int ans
=0,m
=strlen(pat
),n
=strlen(text
);
23 for (int i
=0; i
<n
; i
++) {
24 while (q
>-1 && pat
[q
+1]!=text
[i
]) q
=next
[q
];
25 if (pat
[q
+1]==text
[i
]) q
++;
37 scanf("%s%s",pat
,text
);
39 printf("%d\n",kmp_match());