zoukankan      html  css  js  c++  java
  • poj 1936 All in All

    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 generated and inserted into the original message. To validate your method, however, it is necessary to write a program that checks if the message is really encoded in the final string.

    Given two strings s and t, you have to decide whether s is a subsequence of t, i.e. if you can remove characters from t such that the concatenation of the remaining characters is s.

    Input

    The input contains several testcases. Each is specified by two strings s, t of alphanumeric ASCII characters separated by whitespace.The length of s and t will no more than 100000.

    Output

    For each test case output "Yes", if s is a subsequence of t,otherwise output "No".

    Sample Input

    sequence subsequence
    person compression
    VERDI vivaVittorioEmanueleReDiItalia
    caseDoesMatter CaseDoesMatter
    

    Sample Output

    Yes
    No
    Yes
    No
    
     1 #include<stdio.h>
     2 #include<string.h>
     3 #define MAX 100005
     4 char str1[MAX],str2[MAX];
     5 int main()
     6 {
     7     int i,j;
     8     int len1,len2;
     9     while(~scanf("%s %s",str1,str2))
    10     {
    11         len1=strlen(str1);
    12         len2=strlen(str2);
    13         j=0;
    14         for(i=0;i<len2;i++)
    15         {
    16             if(str2[i]==str1[j])j++;
    17         }
    18         if(j==len1)printf("Yes
    ");
    19         else printf("No
    ");
    20     }return 0;
    21 }
  • 相关阅读:
    互联网某些方面代替了朋友的作用
    穷人
    血脉之力
    鹤立鸡群
    如果有了一个进化的机会,你会选择放弃人类这个身份么?
    怎么样的制度才算是好制度
    /etc/fstab 参数详解及如何设置开机自动挂载
    Linux 查看系统硬件信息(实例详解)
    Linux下添加新硬盘,分区及挂载
    Quartz.NET
  • 原文地址:https://www.cnblogs.com/wlc297984368/p/3267152.html
Copyright © 2011-2022 走看看