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\n"); 14 break; 15 } 16 else if(j==len2){ 17 printf("No\n"); 18 break; 19 } 20 if(s1[i]==s2[j]) 21 i++,j++; 22 else 23 j++; 24 } 25 } 26 return 0; 27 }
把每一件简单的事情做好,就是不简单;把每一件平凡的事情做好,就是不平凡!相信自己,创造奇迹~~