zoj1970||poj 1936 All in All

注意细节,一直把Yes,写成YES,找错误找了老半天都找不出来。。。。

代码如下:

#include<stdio.h>
#include<string.h>
int main()
{
   char s[100005],t[100005];
  int m,i,j,n;
  while(scanf("%s%s",s,t)!=EOF)
  {
    m=strlen(t);
    n=strlen(s);
    i=0;
   for(j=0;j<m;j++)//关键步骤,只判定b数组是否到头,复杂度o(n),
     {
	  if(s[i]==t[j])
	   i++;
     }
    if(i==n)
       printf("Yes\n");
    else
      printf("No\n");
  }
  return 0;
}
时间: 2024-11-05 23:37:01

zoj1970||poj 1936 All in All的相关文章

POJ 1936.All in All

All in All Time Limit:1000MS     Memory Limit:30000KB     64bit IO Format:%I64d & %I64u Submit Status Practice POJ 1936 Description You have devised a new encryption technique which encodes a message by inserting between its characters randomly gener

[ACM] POJ 1936 All in All (查找,一个串是否在另一个串中)

All in All Time Limit: 1000MS   Memory Limit: 30000K Total Submissions: 27521   Accepted: 11266 Description You have devised a new encryption technique which encodes a message by inserting between its characters randomly generated strings in a clever

POJ 1936 All in All 题解

寻找一个串是否是另外一个字符串的子串序列. 可以想象主串是一连发子弹,而需要查找的子串是一队敌人,然后主串的字符是目标,把主串的所有子弹打完,是否能把子串的所有敌人消灭掉. 很简单的题目. #include <stdio.h> const int MAX_N = 100001; char seq[MAX_N], subSeq[MAX_N]; int main() { while (~scanf("%s %s", subSeq, seq)) { char *s = seq,

POJ 1936 All in All 匹配, 水题 难度:0

题目 http://poj.org/problem?id=1936 题意 多组数据,每组数据有两个字符串A,B,求A是否是B的子串.(注意是子串,也就是不必在B中连续) 思路 设置计数器cnt为当前已匹配A的长度,明显在扫描B的过程中只需要记住cnt这一个状态. 扫描B,每次与A[cnt]匹配就将计数器增加1,cnt与A的长度一致时A就是B的子串. 感想 这道题也许可以用更复杂的方法. 代码 1 #include <cstdio> 2 #include <cstring> 3 #i

POJ 1936

Description You have devised a new encryption technique which encodes a message by inserting between its characters randomly generated strings in a clever way. Because of pending patent issues we will not discuss in detail how the strings are generat

All in All - poj 1936 (子串)

字符串子序列查找问题,设置两个指针,一个指向子序列,另一个指向待查找的序列,查找个字符串一次即可判断. 1 #include <iostream> 2 #include <string.h> 3 using namespace std; 4 char s[100002]; 5 char t[100002]; 6 int main() { 7 8 while(cin>>s>>t){ 9 int length1=strlen(s); 10 int length2

POJ 1936 All in All(串)

All in All Time Limit: 1000MS Memory Limit: 30000K Total Submissions: 27537 Accepted: 11274 Description You have devised a new encryption technique which encodes a message by inserting between its characters randomly generated strings in a clever way

POJ 1936 All in All(string)

All in All Time Limit: 1000MS   Memory Limit: 30000K       Description You have devised a new encryption technique which encodes a message by inserting between its characters randomly generated strings in a clever way. Because of pending patent issue

POJ题目分类推荐 (很好很有层次感)

著名题单,最初来源不详.直接来源:http://blog.csdn.net/a1dark/article/details/11714009 OJ上的一些水题(可用来练手和增加自信) (POJ 3299,POJ 2159,POJ 2739,POJ 1083,POJ 2262,POJ 1503,POJ 3006,POJ 2255,POJ 3094) 初期: 一.基本算法: 枚举. (POJ 1753,POJ 2965) 贪心(POJ 1328,POJ 2109,POJ 2586) 递归和分治法. 递