zoukankan      html  css  js  c++  java
  • 百练 1936 ll in All 解题报告

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

    2.题目:

    总时间限制:
    1000ms
    内存限制:
    65536kB
    描述
    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.
    输入
    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判断是否结束

  • 相关阅读:
    基于JavaFXWJFXGameEngine游戏引擎介绍与进度
    进程线程与cpu绑定
    [Vim练级攻略] Vim基础操作
    hdu 2159 fate
    python的httplib注意事项
    SQL优化总结
    项目整体开发流程以及配置人员
    hdu 1010 解题报告 Tempter of the Bone
    在centos搭建git服务器时,不小心把/home/git目录删除了,我是怎么恢复的
    int 和bigint差别有多大?
  • 原文地址:https://www.cnblogs.com/mobileliker/p/3117837.html
Copyright © 2011-2022 走看看