poj 1936 求一个串 是否为 另一个的自串(可以不连续)

来源:互联网 发布:jdk 7u79 windows x86 编辑:程序博客网 时间:2024/06/05 20:11
#include<cstdio>#include<cstring>char str1[100010],str2[100010];int main(){while(~scanf("%s%s",str1,str2)){int len1=strlen(str1);int len2=strlen(str2);if(len1>len2){printf("No\n");continue;}int tot=0;for(int i=0;i<len2;i++){if(str2[i]==str1[tot])tot++;}if(tot==len1)printf("Yes\n");elseprintf("No\n");}return 0;}

0 0