zoukankan      html  css  js  c++  java
  • POJ 1936 All in All(模拟)

    All in All

    题目链接:http://poj.org/problem?id=1936

    题目大意:判断从字符串s2中能否找到子串s1。字符串长度为10W。

    Sample Input

    sequence subsequence
    person compression
    VERDI vivaVittorioEmanueleReDiItalia
    caseDoesMatter CaseDoesMatter
    

    Sample Output

    Yes
    No
    Yes
    No

    分析:这明明是模拟题,有人竟然把它归为动态规划,是要用LCS做吗

    代码如下:

     1 # include<stdio.h>
     2 # include<string.h>
     3 # define MAX 100005
     4 char s1[MAX],s2[MAX];
     5 int main(){
     6     while(scanf("%s%s",s1,s2)!=EOF){
     7         int len1 = strlen(s1);
     8         int len2 = strlen(s2);
     9         int i=0;
    10         int j=0;
    11         while(1){
    12             if(i==len1){
    13                 printf("Yes
    ");
    14                 break;
    15             }
    16             else if(j==len2){
    17                 printf("No
    ");
    18                 break;
    19             }
    20             if(s1[i]==s2[j])
    21                 i++,j++;
    22             else
    23                 j++;
    24         }
    25     }
    26     return 0;
    27 }
  • 相关阅读:
    旅行
    赛道修建
    逃学的小孩
    hdu4035_概率dp
    hdu4405_概率dp
    poj2096_概率dp
    poj3420_找规律+矩阵快速幂
    poj2411_状压dp
    poj3744_矩阵快速幂
    hdu5720_贪心
  • 原文地址:https://www.cnblogs.com/acm-bingzi/p/3281792.html
Copyright © 2011-2022 走看看