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 }
  • 相关阅读:
    python05-循环
    python03-列表
    python03 input
    python02-灭霸的选择
    python学习小记01--萌新的进化
    Linux—-软件安装
    linux-认识与分析日志
    Esxi遇到问题汇总。
    xx
    Pramp mock interview (4th practice): Matrix Spiral Print
  • 原文地址:https://www.cnblogs.com/wlc297984368/p/3267152.html
Copyright © 2011-2022 走看看