百练 1936 ll in All 解题呈报

    添加时间:2013-6-4 点击量:

    1.链接:http://poj.grids.cn/practice/1936/


    2.题目:


    总时候限制:
    1000ms
    内存限制:
    65536kB
    描述
    You have devised a new encryption technique which encodes a message by ing 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 ed 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 t such
    that the concatenation of the remaining characters is s.
    输入
    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.
    输出
    For each test case output Yes, if s is a subsequence of t,otherwise output No.
    样例输入

    sequence subsequence
    
    person compression
    VERDI vivaVittorioEmanueleReDiItalia
    caseDoesMatter CaseDoesMatter

    样例输出

    Yes
    
    No
    Yes
    No


    3.代码:



     1 #include <iostream>
    
    2 #include <cstdio>
    3 #include <cstring>
    4 #include <cstdlib>
    5 using namespace std;
    6 int main()
    7 {
    8 //freopen(F:\\input.txt,r,stdin);
    9
    10
    11 char s[100001],t[100001];
    12 while(scanf(%s %s,s,t) != EOF)
    13 {
    14 int len1 = strlen(s);
    15 int len2 = strlen(t);
    16 int i,j;
    17
    18 i = 0;j = 0;
    19 while(i < len1 && j < len2)
    20 {
    21 if(s[i] == t[j]) i++;
    22 j++;
    23 }
    24 if(i >= len1) cout<<Yes<<endl;
    25 else cout<<No<<endl;
    26 }
    27 return 0;
    28 }


    4.思路:


    1.应用scanf(%s %s,s,t) != EOF断定是否停止

    无论对感情还是对生活,“只要甜不要苦”都是任性而孩子气的,因为我们也不完美,我们也会伤害人。正因为我们都不完美,也因为生活从不是事事如意,所以对这些“瑕疵”的收纳才让我们对生活、对他人的爱变得日益真实而具体。—— 汪冰《世界再亏欠你,也要敢于拥抱幸福》
    分享到: