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 }
  • 相关阅读:
    ffmpeg
    HDU 1031 Design T-Shirt
    HDU 1029 Ignatius and the Princess IV
    HDU 1022 Train Problem I
    HDU 1017 A Mathematical Curiosity
    HDU 1015 Safecracker
    HDU 1002 A + B Problem II
    HDU 1070 Milk
    高精度算法(一)
    codeblocks 使用心得
  • 原文地址:https://www.cnblogs.com/wlc297984368/p/3267152.html
Copyright © 2011-2022 走看看