hdu 4150 Powerful Incantation
生活随笔
收集整理的這篇文章主要介紹了
hdu 4150 Powerful Incantation
小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.
? ?計(jì)算字符串重復(fù)出現(xiàn)的次數(shù)。
可以用KMP來做。
#include<cstdio> #include<iostream> #include<cstring> using namespace std; int main() {int t;scanf("%d",&t);while(t--){int i,j;char str[1000005],str1[10];scanf("%s %s",str,str1);int l1=strlen(str),l2=strlen(str1);int ans=0;for(i=0;i<l1;){int k=i;for(j=0;j<l2;){if(str[k]==str1[j]) {j++;k++;continue;}else break;}if(j==l2){i+=l2;ans++;}else i++;}printf("%d\n",ans);} }總結(jié)
以上是生活随笔為你收集整理的hdu 4150 Powerful Incantation的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: set 结构体
- 下一篇: hdu 4143 A Simple P