`
com_xpp
  • 浏览: 377464 次
社区版块
存档分类
最新评论

Binary String Matching

 
阅读更多

/*日期:2011-10-13
作者:xiaosi
题目:Binary String Matching
*/
#include<iostream>
#include<cstdio>
#include<string>
using namespace std;

int main()
{
int n;
while(scanf("%d",&n)!=EOF)
{
while(n--)
{
int i,j,k,len_a,len_b,count=0;
string a,b;
cin>>a;cin>>b;
len_a=a.length();
len_b=b.length();
for(j=0;j<len_b;j++)
{
k=j;
for(i=0;i<len_a;i++,k++)
{
if(a[i]!=b[k])
{
break;
}
}
if(i==len_a)
{
count++;
}
}
printf("%d\n",count);
}
}
return 0;
}

分享到:
评论

相关推荐

    ACM 算法实现 Java语言

    7. **5 Binary String Matching .txt**:二进制串的匹配问题,可能与位操作和字符串搜索算法有关,如KMP或Boyer-Moore算法。 8. **11 奇偶分离.txt**:可能涉及到数组的奇偶元素分离,需要用到双指针技术。 9. **...

    OJ部分习题及解答(c语言)

    9. **5-Binary String Matching.c**:这是一个关于二进制字符串处理的问题,可能涉及到位操作、字符串搜索或者模式匹配算法。 10. **263-精挑细选.c**:这可能是数据结构相关的题目,可能需要使用堆、栈、队列或者...

    南阳理工学院OJ第1版解题报告V1.0.pdf

    BinaryStringMatching 字符串匹配问题,对于小规模数据集,可以直接暴力搜索。然而,当数据量增大时,高效的算法如KMP、Rabbin-Karp变得至关重要,这需要学生掌握更多高级搜索策略。 #### 6. 喷水装置(一) 贪心...

    Tries and String Matching - Slides - 2009 (Small09)-计算机科学

    ● Red/black trees ≡ 2-3-4 trees, binomialheaps ≡ binary numbers, etc.● Amortized Analysis ● Aggregate, banker's, and potential methods.Where We're Going● String Data Structures ● Data ...

    介绍 Erlang binary 和 bit string 数据类型的经典文章

    - **Pattern Matching**:在进行模式匹配时,Erlang 会尽可能减少对 binary 内部结构的访问,以提高匹配速度。 这些改进对于提高 Erlang 在处理大量二进制数据时的性能具有重要意义。根据作者提供的性能数据显示,...

    The Algorithm Design Manual (2rd Edition)

    8.2 Approximate String Matching 8.3 Longest Increasing Sequence 8.4 War Story: Evolution of the Lobster 8.5 The Partition Problem 8.6 Parsing Context-Free Grammars 8.7 Limitations of Dynamic ...

    麻省理工算法导论(完整精辟版)

    Chapter 32 - String Matching Chapter 33 - Computational Geometry Chapter 34 - NP-Completeness Chapter 35 - Approximation Algorithms Part VIII - Appendix: Mathematical Background Appendix A ...

    【麻省理工大学】算法导论

    Chapter 32 - String Matching Chapter 33 - Computational Geometry Chapter 34 - NP-Completeness Chapter 35 - Approximation Algorithms Part VIII - Appendix: Mathematical Background Appendix A ...

    LuaUnicode icu-lua

    But see the sections below on pattern matching and string equality. Unicode Lua programs Literal Unicode strings can appear in your lua programs. Either a UTF-8 encoded string can appear directly ...

    [麻省理工学院-算法导论](英文版).chm

    Chapter 32 - String Matching Chapter 33 - Computational Geometry Chapter 34 - NP-Completeness Chapter 35 - Approximation Algorithms Part VIII - Appendix: Mathematical Background Appendix A ...

    算法导论(英文第2版)

    Chapter 32 - String Matching Chapter 33 - Computational Geometry Chapter 34 - NP-Completeness Chapter 35 - Approximation Algorithms Part VIII - Appendix: Mathematical Background Appendix A ...

    算法导论英文版

    32.3 String matching with finite automata 916 32.4 The Knuth-Morris-Pratt algorithm 923 33 Computational Geometry 933 33.l Line--segment properties 934 33.2 Determining whether any pair of segments ...

    [麻省理工学院-算法导论].Introduction.to. Algorithms,.Second.Edition

    Chapter 32 - String Matching Chapter 33 - Computational Geometry Chapter 34 - NP-Completeness Chapter 35 - Approximation Algorithms Part VIII - Appendix: Mathematical Background Appendix A ...

    算法导论--Introduction.to.Algorithms

    from classical algorithms in graph theory to special algorithms for string matching, computational geometry, and number theory. The revised third edition notably adds a chapter on van Emde Boas trees...

    leetcode是收费的吗-Node-Search-Algorithms:基于众所周知的算法制作的Node.js和javascript搜索库,

    leetcode是收费的吗 ...Binary Search Tree Search Genetic Algorithm Combinatorial optimization Hashing Internet search algorithms Metaheuristics String matching algorithms Linear Search Binar

    动态规划 近似串匹配.ppt

    7.3 近似串匹配(Approximate String Matching) 近似串匹配是动态规划的一种应用,可以将一个串与另一个串进行比较,找到最相似的子串。这个问题可以通过动态规划来解决,时间复杂度为 O(n^2)。 矩阵连乘的顺序...

    算法设计与分析基础第二版

    * 字符串匹配(String Matching):通过查找字符串中特定的模式来实现。 对于图问题,常见的图算法包括: * 图遍历(Graph Traversal):通过遍历图结构来实现搜索或排序。 * 最短路径问题(Shortest Path Problem...

Global site tag (gtag.js) - Google Analytics